Пример #1
0
def teardown_function(function):
    """ teardown any state that was previously setup with a setup_function
    call.
    """
    subarray = SubArray(1)
    if (resource('ska_low/tm_subarray_node/1').get('State') == "ON"):
        #this means there must have been an error
        if (resource('ska_low/tm_subarray_node/1').get('obsState') == "IDLE"):
            LOGGER.info("tearing down composed subarray (IDLE)")
            # subarray.deallocate() #TODO: Once the OET latest charts are available this can be reverted
            tmc.release_resources()
    if (resource('ska_low/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()
        LOGGER.info("End is invoked on Subarray 1")
        # subarray.deallocate() #TODO: Once the OET latest charts are available this can be reverted
        tmc.release_resources()
        LOGGER.info("ReleaseResources is invoked on Subarray 1")
    if (resource('ska_low/tm_subarray_node/1').get('obsState') == "CONFIGURING"
        ):
        LOGGER.warn(
            "Subarray is still in configuring! Please restart MVP manualy to complete tear down"
        )
        restart_subarray_low(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")
Пример #2
0
def teardown_function(function):
    """ teardown any state that was previously setup with a setup_function
    call.
    """
    if (resource('ska_low/tm_subarray_node/1').get("obsState") == "IDLE"):
        LOGGER.info("Release all resources assigned to subarray")
        # subarray = SubArray(1)
        # subarray.deallocate() #TODO: Once the OET latest charts are available this can be reverted
        tmc.release_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")
Пример #3
0
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")
Пример #4
0
def test_assign_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("Staring up the Telescope")
        tmc.start_up()
        fixture["state"] = "Telescope On"
        # when I assign resources to subarray
        # @log_it('TMC_int_comp',devices_to_log)
        @sync_assign_resources(150)
        def compose_sub():
            resource("ska_low/tm_subarray_node/1").assert_attribute(
                "State").equals("ON")
            resource("ska_low/tm_subarray_node/1").assert_attribute(
                "obsState").equals("EMPTY")
            assign_resources_file = (
                "resources/test_data/TMC_integration/mccs_assign_resources.json"
            )
            assign_resources_str = load_config_from_file(assign_resources_file)
            CentralNode = DeviceProxy("ska_low/tm_central/central_node")
            CentralNode.AssignResources(assign_resources_str)
            LOGGER.info("Invoked AssignResources on CentralNode")

        compose_sub()

        # tear down
        LOGGER.info("Tests complete: tearing down...")
        tmc.release_resources()
        tmc.set_to_standby()

    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()
        raise
Пример #5
0
def teardown_function(function):
    """ teardown any state that was previously setup with a setup_function
    call.
    """
    if (resource('ska_low/tm_subarray_node/1').get('State') == "ON"):
        if (resource('ska_low/tm_subarray_node/1').get('obsState') == "IDLE"):
            LOGGER.info("tearing down composed subarray (IDLE)")
            # subarray.deallocate() #TODO: Once the OET latest charts are available this can be reverted
            tmc.release_resources()
            LOGGER.info('Invoked ReleaseResources on Subarray')
            wait_before_test(timeout=10)
        if (resource('ska_low/tm_subarray_node/1').get('obsState') == "READY"):
            LOGGER.info("tearing down configured subarray (READY)")
            take_subarray(1).and_end_sb_when_ready()
            LOGGER.info('Invoked End on Subarray')
            wait_before_test(timeout=10)
            # subarray.deallocate() #TODO: Once the OET latest charts are available this can be reverted
            tmc.release_resources()
            LOGGER.info('Invoked ReleaseResources on Subarray')
            wait_before_test(timeout=10)
        if (resource('ska_low/tm_subarray_node/1').get('obsState') ==
                "CONFIGURING"):
            LOGGER.warn(
                "Subarray is still in CONFIFURING! Please restart MVP manualy to complete tear down"
            )
            restart_subarray_low(1)
            # raise exception since we are unable to continue with tear down
            raise Exception("Unable to tear down test setup")
        if (resource('ska_low/tm_subarray_node/1').get('obsState') ==
                "SCANNING"):
            LOGGER.warn(
                "Subarray is still in SCANNING! Please restart MVP manualy to complete tear down"
            )
            restart_subarray_low(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()
    else:
        LOGGER.warn(
            "Subarray is in inconsistent state! Please restart MVP manualy to complete tear down"
        )
        restart_subarray_low(1)
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")
Пример #7
0
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")
Пример #9
0
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")
Пример #10
0
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")