def end(result): """ teardown any state that was previously setup for the tests. Args: result (dict): fixture to track test state """ subarray = SubArray(1) obsstate = resource(result[SUBARRAY_USED]).get('obsState') if obsstate == "IDLE": LOGGER.info("CLEANUP: tearing down composed subarray (IDLE)") subarray.deallocate() if obsstate == "READY": LOGGER.info("CLEANUP: tearing down configured subarray (READY)") subarray.end() subarray.deallocate() if obsstate in ["RESOURCING", "CONFIGURING", "SCANNING"]: LOGGER.warning( "Subarray is still in %s Please restart MVP manually to complete tear down", obsstate) subarray.restart() # 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 ", resource(result[SUBARRAY_USED]).get('obsState'))
def end(result): """ teardown any state that was previously setup with a setup_function call. """ subarray = SubArray(1) obsstate = resource(result[SUBARRAY_USED]).get('obsState') if obsstate == "IDLE": LOGGER.info("CLEANUP: tearing down composed subarray (IDLE)") subarray.deallocate() set_telescope_to_standby()
class pilot: def __init__(self, id): self.SubArray = SubArray(id) self.logs = "" self.agents = ResourceGroup(resource_names=subarray_devices) self.state = "Empty" self.rollback_order = { "Composed": self.and_release_all_resources, "Ready": self.and_end_sb_when_ready, # 'Configuring':restart_subarray, # 'Scanning':restart_subarray } def and_display_state(self): print("state at {} is:\n{}".format(datetime.now(), self.agents.get("State"))) return self def and_display_obsState(self): print("state at {} is:\n{}".format(datetime.now(), self.agents.get("obsState"))) return self ##the following methods are implemented versions of what gets tested ##unless a specic version is tested they should be exactly the same def to_be_composed_out_of( self, dishes, file="resources/test_data/OET_integration/example_allocate.json"): ##Reference tests/acceptance/mvp/test_XR-13_A1.py @sync_assign_resources(dishes, 600) def assign(): sdp_block = update_resource_config_file(file) resource_request: AssignResourcesRequest = cdm_CODEC.load_from_file( AssignResourcesRequest, file) resource_request.dish.receptor_ids = [ str(x).zfill(4) for x in range(1, dishes + 1) ] self.SubArray.allocate_from_cdm(resource_request) return sdp_block sdp_block = assign() self.state = "Composed" LOGGER.info("_________Sdp block from composed function_______" + str(self) + str(sdp_block)) return self, sdp_block def and_configure_scan_by_file( self, sdp_block, file="resources/test_data/OET_integration/example_configure.json", ): ##Reference tests/acceptance/mvp/test_XR-13_A2-Test.py @sync_configure_oet @time_it(120) def config(file, sdp_block): update_scan_config_file(file, sdp_block) LOGGER.info("___________Input file in configure_oet_____________" + str(file)) self.state = "Configuring" self.SubArray.configure_from_file(file, 6, with_processing=False) LOGGER.info("___________SDP block from configure_oet_____________" + str(sdp_block)) config(file, sdp_block) self.state = "Ready" return self def and_run_a_scan(self): ##Reference tests/acceptance/mvp/test_XR-13_A3-Test.py ##note this is a different sync decorator as test since test performs the command as non blocking # @sync_scan_oet def scan(): self.SubArray.scan() scan() self.state = "Ready" return self def and_release_all_resources(self): @sync_release_resources def de_allocate(): self.SubArray.deallocate() de_allocate() self.state = "Empty" return self def and_end_sb_when_ready(self): @sync_end_sb def end_sb(): self.SubArray.end() end_sb() self.state = "Composed" return self def restart_when_aborted(self): @sync_restart_sa def restart(): self.SubArray.restart() restart() self.state = "EMPTY" return self def reset_when_aborted(self): @sync_reset_sa def reset(): self.SubArray.reset() reset() self.state = "IDLE" return self def roll_back(self): if self.state != "Empty": self.rollback_order[self.state]() def reset(self): while self.state != "Empty": self.rollback_order[self.state]()