def end(result): """ teardown any state that was previously setup with a setup_function call. """ LOGGER.info("End of test: Resetting Telescope") if resource('ska_mid/tm_subarray_node/1').get("obsState") == "IDLE": LOGGER.info("Release all resources assigned to subarray") take_subarray(1).and_release_all_resources() if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "READY"): LOGGER.info("tearing down configured subarray (READY)") take_subarray(1).and_end_sb_when_ready().and_release_all_resources() if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "CONFIGURING" ): LOGGER.warn( "Subarray is still in CONFIFURING! Please restart MVP manually to complete tear down" ) restart_subarray(1) #raise exception since we are unable to continue with tear down raise Exception("Unable to tear down test setup") if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "SCANNING"): LOGGER.warn( "Subarray is still in SCANNING! Please restart MVP manually to complete tear down" ) restart_subarray(1) #raise exception since we are unable to continue with tear down raise Exception("Unable to tear down test setup") LOGGER.info("Put Telescope back to standby") set_telescope_to_standby()
def teardown_function(function): """ teardown any state that was previously setup with a setup_function call. """ if (resource('ska_mid/tm_subarray_node/1').get('State') == "ON"): #this means there must have been an error if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "IDLE"): LOGGER.info("tearing down composed subarray (IDLE)") take_subarray(1).and_release_all_resources() if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "READY"): #this means test must have passed LOGGER.info("tearing down configured subarray (READY)") take_subarray(1).and_end_sb_when_ready().and_release_all_resources() LOGGER.info("EndSb and ReleaseResources is involked on Subarray 1") if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "CONFIGURING" ): LOGGER.warn( "Subarray is still in configuring! Please restart MVP manualy to complete tear down" ) restart_subarray(1) #raise exception since we are unable to continue with tear down raise Exception("Unable to tear down test setup") LOGGER.info("Put Telescope back to standby") set_telescope_to_standby() LOGGER.info("Telescope is in standby")
def end(result): """ teardown any state that was previously setup for the tests. Args: result (dict): fixture to track test state """ subarray = resource(result[SUBARRAY_USED]) obsstate = subarray.get('obsState') LOGGER.info("CLEANUP: Sub-array in obsState %s ", obsstate) if obsstate == "IDLE": LOGGER.info("CLEANUP: tearing down composed subarray (IDLE)") take_subarray(1).and_release_all_resources() if obsstate == "READY": LOGGER.info("CLEANUP: tearing down configured subarray (READY)") take_subarray(1).and_end_sb_when_ready( ).and_release_all_resources() if subarray.get('obsState') != "EMPTY": LOGGER.warning( "Subarray is still in %s Please restart MVP manually to complete tear down", obsstate) restart_subarray(1) # raise exception since we are unable to continue with tear down raise Exception("Unable to tear down test setup") if not telescope_is_in_standby(): set_telescope_to_standby() LOGGER.info("CLEANUP: Sub-array is in %s ", subarray.get('obsState'))
def teardown_function(function): """teardown any state that was previously setup with a setup_function call. """ if resource("ska_mid/tm_subarray_node/1").get("State") == "ON": if resource("ska_mid/tm_subarray_node/1").get("obsState") == "IDLE": LOGGER.info("tearing down composed subarray (IDLE)") take_subarray(1).and_release_all_resources() LOGGER.info( "Resources are deallocated successfully from Subarray.") if resource("ska_mid/tm_subarray_node/1").get("obsState") == "CONFIGURING": LOGGER.warn( "Subarray is still in CONFIFURING! Please restart MVP manually to complete tear down" ) restart_subarray(1) raise Exception("Unable to tear down test setup") if resource("ska_mid/tm_subarray_node/1").get("obsState") == "READY": LOGGER.info("tearing down configured subarray (READY)") take_subarray(1).and_end_sb_when_ready().and_release_all_resources() if resource("ska_mid/tm_subarray_node/1").get("obsState") == "SCANNING": LOGGER.warn( "Subarray is still in SCANNING! Please restart MVP manually to complete tear down" ) restart_subarray(1) raise Exception("Unable to tear down test setup") if resource("ska_mid/tm_subarray_node/1").get("obsState") == "ABORTING": LOGGER.warn( "Subarray is still in ABORTING! Please restart MVP manually to complete tear down" ) restart_subarray(1) if resource("ska_mid/tm_subarray_node/1").get("obsState") == "ABORTED": take_subarray(1).restart_when_aborted() LOGGER.info("Put Telescope back to standby") set_telescope_to_standby() LOGGER.info("Telescope is in StandBy.")
def end(result): """ teardown any state that was previously setup with a setup_function call. """ obsstate = resource(result[SUBARRAY_USED]).get('obsState') if obsstate == "IDLE": LOGGER.info("CLEANUP: tearing down composed subarray (IDLE)") take_subarray(1).and_release_all_resources() set_telescope_to_standby()
def set_telescope_in_off_state(result): """ Set telescope to OFF state (stand-by) if it is not yet OFF. """ LOGGER.info("Set telescope to stand-by") if resource(result[CENTRAL_NODE_USED]).get('telescopeState') != 'STANDBY': set_telescope_to_standby() assert telescope_is_in_standby(), \ f"Telescope is not in STANDBY" LOGGER.info("Telescope is in STANDBY")
def teardown_function(function): """ teardown any state that was previously setup with a setup_function call. """ if (resource('ska_mid/tm_subarray_node/1').get("obsState") == "IDLE"): LOGGER.info("Release all resources assigned to subarray") take_subarray(1).and_release_all_resources() LOGGER.info("ResourceIdList is empty for Subarray 1 ") LOGGER.info("Put Telescope back to standby") set_telescope_to_standby() LOGGER.info("Telescope is in standby")
def end(result): """ teardown any state that was previously setup with a setup_function call. """ obsstate = resource(result[SUBARRAY_USED]).get('obsState') LOGGER.info("CLEANUP: Sub-array in obsState %s ", obsstate) if obsstate == "IDLE": LOGGER.info("CLEANUP: tearing down composed sub-array (IDLE)") take_subarray(1).and_release_all_resources() if obsstate == "ABORTED": LOGGER.info("CLEANUP: restarting aborted sub-array") sub = SubArray(1) sub.restart() if obsstate in ["RESOURCING", "RESTARTING", "RESETTING", "ABORTING"]: LOGGER.warning( "Subarray is still in %s Please restart MVP manually to complete tear down", obsstate) raise Exception("Unable to tear down test setup") set_telescope_to_standby()
def teardown_function(function): """ teardown any state that was previously setup with a setup_function call. """ if (resource('ska_mid/tm_subarray_node/1').get('State') == "ON"): if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "IDLE"): LOGGER.info("tearing down composed subarray (IDLE)") take_subarray(1).and_release_all_resources() if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "CONFIGURING" ): LOGGER.warn( "Subarray is still in CONFIFURING! Please restart MVP manually to complete tear down" ) restart_subarray(1) raise Exception("Unable to tear down test setup") if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "READY"): LOGGER.info("tearing down configured subarray (READY)") take_subarray(1).and_end_sb_when_ready().and_release_all_resources() if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "ABORTING"): LOGGER.warn( "Subarray is still in ABORTING! Please restart MVP manually to complete tear down" ) restart_subarray(1) raise Exception("Unable to tear down test setup") if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "SCANNING"): LOGGER.warn( "Subarray is still in SCANNING! Please restart MVP manually to complete tear down" ) restart_subarray(1) raise Exception("Unable to tear down test setup") if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "RESTARTING" ): LOGGER.warn( "Subarray is still in RESTARTING! Please restart MVP manually to complete tear down" ) restart_subarray(1) raise Exception("Unable to tear down test setup") if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "EMPTY"): LOGGER.info("Subarray is in EMPTY state.") LOGGER.info("Put Telescope back to standby") set_telescope_to_standby() LOGGER.info("Telescope is in standby")
def test_tm_subarray_inconsistent_at_start_up(): try: LOGGER.info( "Before starting the telescope checking if the TMC is in ON state") assert (tmc_is_on()) LOGGER.info( "Before starting the telescope checking if the telescope is in StandBy." ) assert telescope_is_in_standby() LOGGER.info("Telescope is in StandBy.") LOGGER.info("Invoking Startup Telescope command on the telescope.") set_telescope_to_running() LOGGER.info("Telescope is started successfully.") resource('ska_mid/tm_central/central_node').assert_attribute( 'telescopeState').equals('ON') #teardown finally: if not telescope_is_in_standby(): set_telescope_to_standby()
def test_start_up_telescope(run_context): LOGGER.info( "Before starting the telescope checking if the TMC is in ON state") assert (tmc_is_on()) LOGGER.info( "Before starting the telescope checking if the telescope is in StandBy." ) assert (telescope_is_in_standby) jsonLogin = {"username": "******", "password": "******"} url = 'http://taranta-taranta-{}:8080/login'.format( run_context.HELM_RELEASE) r = requests.post(url=url, json=jsonLogin) taranta_jwt = r.cookies.get_dict()['taranta_jwt'] cookies = {'taranta_jwt': taranta_jwt} url = 'http://taranta-taranta-{}:5004/db'.format(run_context.HELM_RELEASE) # with open('test-harness/files/mutation.json', 'r') as file: # mutation = file.read().replace('\n', '') mutation = '{"query":"mutation {\\n executeCommand(device: \\"ska_mid/tm_central/central_node\\", command: \\"TelescopeOn\\") {\\n ok\\n output\\n message\\n }\\n}\\n","variables":"null"}' LOGGER.info("Mutation " + str(mutation)) jsonMutation = json.loads(mutation) LOGGER.info("jsonMutation " + str(jsonMutation)) the_waiter = waiter() the_waiter.set_wait_for_starting_up() r = requests.post(url=url, json=jsonMutation, cookies=cookies) the_waiter.wait() LOGGER.info("r.text " + str(r.text)) parsed = json.loads(r.text) LOGGER.info("parsed r.text is " + str(parsed)) print(json.dumps(parsed, indent=4, sort_keys=True)) LOGGER.info("sorted pasrsed r.text " + str(json.dumps(parsed, indent=4, sort_keys=True))) try: assert parsed['data']['executeCommand']['ok'] == True finally: # tear down command is ignored if it is already in standby if not telescope_is_in_standby(): # wait first for telescope to completely go to standby before switchig it off again set_telescope_to_standby() LOGGER.info("Telescope is in STANDBY")
def end(result): """ teardown any state that was previously setup with a setup_function call. """ if resource(result[CENTRAL_NODE_USED]).get('telescopeState') != 'STANDBY': set_telescope_to_standby()