def test_configure_scan(): try: # given an interface to TMC to interact with a subarray node and a central node fixture = {} fixture["state"] = "Unknown" # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Staring up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" # then when I configure a subarray to perform a scan as per 'TMC_integration/mccs_configure.json' # @log_it('TMC_int_configure',devices_to_log) @sync_configure @time_it(90) def configure_sub(): configure1_file = "resources/test_data/TMC_integration/mccs_configure.json" config = load_config_from_file(configure1_file) LOGGER.info("Configuring a scan for subarray 1") fixture["state"] = "Subarray CONFIGURING" SubarrayNode = DeviceProxy("ska_low/tm_subarray_node/1") SubarrayNode.Configure(config) LOGGER.info("Invoked Configure on Subarray") configure_sub() fixture["state"] = "Subarray Configured for SCAN" # tear down LOGGER.info("TMC-configure tests complete: tearing down...") tmc.end() LOGGER.info("Invoked End on Subarray") tmc.release_resources() LOGGER.info("Invoked ReleaseResources on Subarray") tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") except: LOGGER.info("Tearing down failed test, state = {}".format(fixture["state"])) if fixture["state"] == "Telescope On": tmc.set_to_standby() elif fixture["state"] == "Subarray Assigned": tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray Configured for SCAN": LOGGER.info("Tearing down in , state = {}".format(fixture["state"])) tmc.end() tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray SCANNING": raise Exception("unable to teardown subarray from being in SCANNING") elif fixture["state"] == "Subarray CONFIGURING": raise Exception("unable to teardown subarray from being in CONFIGURING") pytest.fail("unable to complete test without exceptions")
def test_release_resources(): try: # given an interface to TMC to interact with a subarray node and a central node fixture = {} fixture["state"] = "Unknown" # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Starting up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/mccs_assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" @sync_release_resources def release_resources(): CentralNodeLow = DeviceProxy("ska_low/tm_central/central_node") release_resources_file = ( "resources/test_data/TMC_integration/mccs_release_resources.json" ) release_resource_str = load_config_from_file(release_resources_file) CentralNodeLow.ReleaseResources(release_resource_str) release_resources() LOGGER.info("Release Resources complete") fixture["state"] = "Subarray Configured for RELEASE RESOURCES" # tear down LOGGER.info("TMC-release resources tests complete: tearing down...") tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") except: LOGGER.info("Tearing down failed test, state = {}".format(fixture["state"])) if fixture["state"] == "Telescope On": tmc.set_to_standby() elif fixture["state"] == "Subarray Assigned": tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Release Resources Completed": LOGGER.info("Tearing down in , state = {}".format(fixture["state"])) tmc.set_to_standby() elif fixture["state"] == "Subarray SCANNING": raise Exception("unable to teardown subarray from being in SCANNING") elif fixture["state"] == "Subarray CONFIGURING": raise Exception("unable to teardown subarray from being in CONFIGURING") pytest.fail("unable to complete test without exceptions")
def test_endscan(): try: # given an interface to TMC to interact with a subarray node and a central node fixture = {} fixture["state"] = "Unknown" # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Starting up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/mccs_assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" # and a subarray configured to perform a scan as per 'TMC_integration/configure1.json' LOGGER.info("Configuring the Subarray") fixture["state"] = "Subarray CONFIGURING" tmc.configure_sub() fixture["state"] = "Subarray Configured for SCAN" # When scan is run for provided duration based on previous configuuration resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("READY") LOGGER.info("Invoked Scan on Subarray") fixture["state"] = "Subarray SCANNING" def endscan(): SubarrayNodeLow = DeviceProxy("ska_low/tm_subarray_node/1") tmc.scan_for_scanning() SubarrayNodeLow.EndScan() endscan() LOGGER.info("EndScan complete") fixture["state"] = "Subarray EndScan invoked" # tear down LOGGER.info("TMC-EndScan tests complete: tearing down...") tmc.end() resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("IDLE") LOGGER.info("Invoked End on Subarray") tmc.release_resources() LOGGER.info("Invoked ReleaseResources on Subarray") tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") except: LOGGER.info("Tearing down failed test, state = {}".format( fixture["state"])) if fixture["state"] == "Telescope On": tmc.set_to_standby() elif fixture["state"] == "Subarray Assigned": tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray Configured for SCAN": tmc.end() tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray SCANNING": raise Exception( "unable to teardown subarray from being in SCANNING") elif fixture["state"] == "Subarray CONFIGURING": raise Exception( "unable to teardown subarray from being in CONFIGURING") pytest.fail("unable to complete test without exceptions")
def test_restart(): try: # given an interface to TMC to interact with a subarray node and a central node fixture = {} fixture["state"] = "Unknown" the_waiter = waiter() # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Starting up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("IDLE") LOGGER.info("Aborting the subarray") fixture["state"] = "Subarray ABORTING" LOGGER.info("Invoking abort command") tmc.abort_sub() fixture["state"] = "Subarray Aborted" fixture["state"] = "Subarray Restarting" @sync_restart() def restart(): SubarrayNodeLow = DeviceProxy("ska_low/tm_subarray_node/1") LOGGER.info( "Subarray obsState before Aborted assertion check is: " + str(SubarrayNodeLow.obsState)) resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("ABORTED") SubarrayNodeLow.Restart() LOGGER.info("Subarray obsState is: " + str(SubarrayNodeLow.obsState)) LOGGER.info("Invoked restart on Subarray") restart() LOGGER.info("Restart is complete on Subarray") LOGGER.info("TMC-Restart tests complete: tearing down...") resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("EMPTY") fixture["state"] = "Subarray empty" tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") fixture["state"] = "Subarray off" LOGGER.info("TMC-Low-Restart tests complete: tearing down...") except: LOGGER.info("Tearing down failed test, state = {}".format( fixture["state"])) if fixture["state"] == "Telescope On": tmc.set_to_standby() elif fixture["state"] == "Subarray Assigned": tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray ABORTING": # restart_subarray(1) raise Exception( "unable to teardown subarray from being in ABORTING") elif fixture["state"] == "Subarray Aborted": # restart_subarray(1) raise Exception( "unable to teardown subarray from being in Aborted") elif fixture["state"] == "Subarray Restarting": # restart_subarray(1) raise Exception( "unable to teardown subarray from being in Restarting") elif fixture["state"] == "Subarray off": LOGGER.info("Subarray has completed StandBy execution") pytest.fail("unable to complete test without exceptions")
def test_scan(): try: # given an interface to TMC to interact with a subarray node and a central node fixture = {} fixture["state"] = "Unknown" # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Starting up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/mccs_assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" # and a subarray configured to perform a scan as per 'TMC_integration/configure1.json' LOGGER.info("Configuring the Subarray") fixture["state"] = "Subarray CONFIGURING" tmc.configure_sub() fixture["state"] = "Subarray Configured for SCAN" # When I run a scan of 4 seconds based on previos configuration resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("READY") LOGGER.info("Starting a scan of 4 seconds") fixture["state"] = "Subarray SCANNING" # @log_it('TMC_int_scan',devices_to_log) @sync_scan(200) def scan(): SubarrayNodeLow = DeviceProxy("ska_low/tm_subarray_node/1") scan_command_file = ( "resources/test_data/TMC_integration/mccs_scan.json") scan_str = load_config_from_file(scan_command_file) SubarrayNodeLow.Scan(scan_str) scan() LOGGER.info("Scan complete") fixture["state"] = "Subarray Configured for SCAN" # tear down LOGGER.info("TMC-Scan tests complete: tearing down...") tmc.end() resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("IDLE") LOGGER.info("Invoked End on Subarray") tmc.release_resources() LOGGER.info("Invoked ReleaseResources on Subarray") tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") except: LOGGER.info("Tearing down failed test, state = {}".format( fixture["state"])) if fixture["state"] == "Telescope On": tmc.set_to_standby() elif fixture["state"] == "Subarray Assigned": tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray Configured for SCAN": tmc.end() tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray SCANNING": raise Exception( "unable to teardown subarray from being in SCANNING") elif fixture["state"] == "Subarray CONFIGURING": raise Exception( "unable to teardown subarray from being in CONFIGURING") pytest.fail("unable to complete test without exceptions")
def test_abort(required_obstate): try: obs_state_val = required_obstate # given an interface to TMC to interact with a subarray node and a central node if obs_state_val == "IDLE": fixture = {} fixture["state"] = "Unknown" # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Starting up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/mccs_assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("IDLE") LOGGER.info("Invoking abort command") tmc.abort_sub() fixture["state"] = "Obstate aborted" LOGGER.info("Invoking Obsreset command") tmc.obsreset_sub() LOGGER.info("Obsreset is complete on Subarray") fixture["state"] = "Subarray IDLE" tmc.release_resources() LOGGER.info("Invoked ReleaseResources on Subarray") tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") elif obs_state_val == "READY": fixture = {} fixture["state"] = "Unknown" # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Starting up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/mccs_assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("IDLE") LOGGER.info("Configuring the Subarray") fixture["state"] = "Subarray CONFIGURING" tmc.configure_sub() fixture["state"] = "Subarray Configured for SCAN" resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("READY") LOGGER.info("Invoking abort command") tmc.abort_sub() fixture["state"] = "Obstate aborted" LOGGER.info("Invoking Obsreset command") tmc.obsreset_sub() LOGGER.info("Obsreset is complete on Subarray") fixture["state"] = "Subarray IDLE" tmc.release_resources() LOGGER.info("Invoked ReleaseResources on Subarray") tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") elif obs_state_val == "SCANNING": fixture = {} fixture["state"] = "Unknown" # given a started up telescope assert telescope_is_in_standby() LOGGER.info("Starting up the Telescope") tmc.start_up() fixture["state"] = "Telescope On" # and a subarray composed of two resources configured as perTMC_integration/mccs_assign_resources.json LOGGER.info("Composing the Subarray") tmc.compose_sub() fixture["state"] = "Subarray Assigned" resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("IDLE") LOGGER.info("Configuring the Subarray") fixture["state"] = "Subarray CONFIGURING" tmc.configure_sub() fixture["state"] = "Subarray Configured for SCAN" resource("ska_low/tm_subarray_node/1").assert_attribute( "obsState").equals("READY") @sync_abort def abort(): SubarrayNodeLow = DeviceProxy("ska_low/tm_subarray_node/1") tmc.scan_for_scanning() SubarrayNodeLow.Abort() LOGGER.info("Invoked Abort on Subarray") abort() LOGGER.info("Abort is complete on Subarray") fixture["state"] = "Subarray Aborted" tmc.obsreset_sub() LOGGER.info("Obsreset is complete on Subarray") fixture["state"] = "Subarray IDLE" tmc.release_resources() LOGGER.info("Invoked ReleaseResources on Subarray") tmc.set_to_standby() LOGGER.info("Invoked StandBy on Subarray") else: msg = "obsState {} is not settable with command methods" raise ValueError(msg.format(obs_state_val)) except: LOGGER.info("Tearing down failed test, state = {}".format( fixture["state"])) if fixture["state"] == "Telescope On": tmc.set_to_standby() elif fixture["state"] == "Subarray Assigned": tmc.release_resources() tmc.set_to_standby() elif fixture["state"] == "Subarray CONFIGURING": raise Exception( "unable to teardown subarray from being in Restarting") elif fixture["state"] == "Subarray ABORTING": raise Exception( "unable to teardown subarray from being in ABORTING") elif fixture["state"] == "Subarray Aborted": raise Exception( "unable to teardown subarray from being in Aborted") elif fixture["state"] == "Subarray Resetting": raise Exception( "unable to teardown subarray from being in Restarting") elif fixture["state"] == "Subarray IDLE": tmc.release_resources() tmc.set_to_standby() pytest.fail("unable to complete test without exceptions")