Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IS-05: Testing scenario when two receivers get bulk-staged for relati… #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions IS0501Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import requests
import uuid
import os
import time
from jsonschema import ValidationError, SchemaError, RefResolver, Draft4Validator

import TestHelper
Expand Down Expand Up @@ -806,6 +807,18 @@ def test_40(self):
else:
return test.NA("Not tested. No resources found.")

def test_41(self):
"""Bulk interface can be used to activate destination port on all receivers"""
test = Test("Bulk interface can be used to activate destination port on all receivers")
if len(self.receivers) > 0:
valid, response = self.check_bulk_active_relative("receiver", self.receivers)
if valid:
return test.PASS()
else:
return test.FAIL(response)
else:
return test.NA("Not tested. No resources found.")


def check_bulk_stage(self, port, portList):
"""Test changing staged parameters on the bulk interface"""
Expand Down Expand Up @@ -867,6 +880,75 @@ def check_bulk_stage(self, port, portList):
return False, response
return True, ""

def check_bulk_active_relative(self, port, portList):
"""Test changing staged parameters on the bulk interface"""
url = self.url + "bulk/" + port + "s"
data = []
ports = {}
for portInst in portList:
valid, response = self.is05_utils.generate_destination_ports(port, portInst)
if valid:
ports[portInst] = response
toAdd = {}
toAdd['id'] = portInst
toAdd['params'] = {}
toAdd['params']['activation'] = {"mode": "activate_scheduled_relative", "requested_time": "0:2"}
toAdd['params']['transport_params'] = []
for portNum in ports[portInst]:
toAdd['params']['transport_params'].append({"destination_port": portNum})
data.append(toAdd)
else:
return False, response
try:
r = requests.post(url, json=data)
msg = "Expected a 200 response from {}, got {}".format(url, r.status_code)
if r.status_code == 200:
pass
else:
return False, msg
except requests.exceptions.RequestException as e:
return False, str(e)

schema = self.get_schema(CONN_API_KEY, "POST", "/bulk/" + port + "s", 200)
try:
Draft4Validator(schema).validate(r.json())
except ValidationError as e:
return False, "Response to post at {} did not validate against schema: {}".format(url, str(e))
except:
return False, "Invalid JSON received {}".format(r.text)

time.sleep(0.5)
# Check the parameters have actually changed
for portInst in portList:
retries = 0
finished = False

while retries < 5 and not finished:
activeUrl = "single/" + port + "s/" + portInst + "/active/"

valid, response = self.is05_utils.checkCleanRequestJSON("GET", activeUrl)
if valid:
for i in range(0, self.is05_utils.get_num_paths(portInst, port)):
try:
value = response['transport_params'][i]['destination_port']
except KeyError:
return False, "Could not find `destination_port` parameter at {} on leg {}, got{}".format(
activeUrl, i,
response)
portNum = ports[portInst][i]
msg = "Problem updating destination_port value in bulk scheduled relative activation, expected {} got {}".format(portNum,
value)
if value == portNum:
finished = True
else:
retries = retries + 1
time.sleep(1)
else:
return False, response
if not finished:
return False, msg
return True, ""

def check_patch_response_schema_valid(self, port, portList):
"""Check the response to an empty patch request complies with the schema"""
for myPort in portList:
Expand Down