Beispiel #1
0
def test_tearing_down_subarray(subscriber_mock, resource_mock, watch_mock):
    the_waiter = waiter()
    the_waiter.set_wait_for_tearing_down_subarray()
    assert_that(resource_mock.call_count).is_equal_to(5)
    #assert_that(subscriber_mock.call_count).is_equal_to(5+4)
    #assert_that(watch_mock.call_count).is_equal_to(5+4)
    the_waiter.wait()
 def wrapper(*args, **kwargs):
     check_going_out_of_configured()
     the_waiter = waiter()
     the_waiter.set_wait_for_going_into_scanning()
     result = func(*args, **kwargs)
     the_waiter.wait()
     return result
 def wrapper(*args, **kwargs):
     check_going_out_of_configured()
     the_waiter = waiter()
     the_waiter.set_wait_for_ending_SB()
     result = func(*args, **kwargs)
     the_waiter.wait(200)
     return result
Beispiel #4
0
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"):
        the_waiter = waiter()
        the_waiter.set_wait_for_tearing_down_subarray()
        SubArray(1).deallocate()
        the_waiter.wait()
        LOGGER.info(the_waiter.logs)
    if (resource('ska_mid/tm_subarray_node/1').get("State") == "OFF"):
        the_waiter = waiter()
        the_waiter.set_wait_for_going_to_standby()
        SKAMid().standby()
        the_waiter.wait()
        LOGGER.info(the_waiter.logs)
 def wrapper(*args, **kwargs):
     check_coming_out_of_standby()
     the_waiter = waiter()
     the_waiter.set_wait_for_starting_up()
     result = func(*args, **kwargs)
     the_waiter.wait(50)
     return result
 def wrapper(*args, **kwargs):
     check_going_out_of_abort()
     the_waiter = waiter()
     the_waiter.set_wait_for_going_into_obsreset()
     result = func(*args, **kwargs)
     the_waiter.wait(100)
     return result
 def wrapper(*args, **kwargs):
     check_going_into_standby()
     the_waiter = waiter()
     the_waiter.set_wait_for_going_to_standby()
     result = func(*args, **kwargs)
     the_waiter.wait(100)
     return result
Beispiel #8
0
def start_up():
    the_waiter = waiter()
    the_waiter.set_wait_for_starting_up()
    SKAMid().start_up()
    the_waiter.wait()
    LOGGER.info("Telescope Started up")
    LOGGER.debug("the_waiter.logs")
Beispiel #9
0
def teardown_function(function):
    """ teardown any state that was previously setup with a setup_function
    call.
    """
    the_waiter = waiter()
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "IDLE"):
        the_waiter.set_wait_for_tearing_down_subarray()
        LOGGER.info("tearing down composed subarray (IDLE)")
        SubArray(1).deallocate()
        the_waiter.wait()
        LOGGER.info(the_waiter.logs)
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "READY"):
        LOGGER.info("tearing down configured subarray (READY)")
        the_waiter.set_wait_for_ending_SB()
        SubArray(1).end_sb()
        the_waiter.wait()
        LOGGER.info(the_waiter.logs)
        the_waiter.set_wait_for_tearing_down_subarray()
        SubArray(1).deallocate()
        the_waiter.wait()
        LOGGER.info(the_waiter.logs)
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "CONFIGURING"):
        LOGGER.info("tearing down configuring subarray")
        restart_subarray(1)
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "SCANNING"):
        LOGGER.info("tearing down scanning subarray")
        restart_subarray(1)
    the_waiter.set_wait_for_going_to_standby()
    SKAMid().standby()
    LOGGER.info("standby command is executed on telescope")
    the_waiter.wait()
    LOGGER.info(the_waiter.logs)
Beispiel #10
0
 def wrapper(*args, **kwargs):
     print("In sync_release_resources")
     check_going_into_empty()
     the_waiter = waiter()
     the_waiter.set_wait_for_tearing_down_subarray()
     result = func(*args, **kwargs)
     the_waiter.wait(150)
     return result
Beispiel #11
0
 def wrapper(*args, **kwargs):
     check_going_out_of_empty()
     the_waiter = waiter()
     the_waiter.set_wait_for_assign_resources(
         nr_of_receptors=nr_of_receptors)
     ################
     result = func(*args, **kwargs)
     ################
     the_waiter.wait(timeout=timeout)
     return result
def compose_sub():
    resource("ska_mid/tm_subarray_node/1").assert_attribute("State").equals(
        "ON")
    resource("ska_mid/tm_subarray_node/1").assert_attribute("obsState").equals(
        "EMPTY")
    assign_resources_file = "resources/test_data/TMC_integration/assign_resources1.json"
    sdp_block = update_resource_config_file(assign_resources_file)
    LOGGER.info("_______sdp_block________" + str(sdp_block))
    config = load_config_from_file(assign_resources_file)
    CentralNode = DeviceProxy("ska_mid/tm_central/central_node")
    CentralNode.AssignResources(config)
    the_waiter = waiter()
    the_waiter.wait()
    LOGGER.info("Invoked AssignResources on CentralNode")
    return sdp_block
Beispiel #13
0
def set_telescope_to_running(disable_waiting=False):
    the_waiter = waiter()
    the_waiter.set_wait_for_starting_up()
    # TODO: Using TMC API for TelescopeOn command.
    # Telescope().start_up()

    CentralNode = DeviceProxy("ska_mid/tm_central/central_node")
    LOGGER.info("Before Sending TelescopeOn command on CentralNode state :" +
                str(CentralNode.telescopeState))
    CentralNode.TelescopeOn()
    the_waiter.wait(5000)
    if not disable_waiting:
        the_waiter.wait(8000)
        if the_waiter.timed_out:
            pytest.fail("timed out whilst starting up telescope:\n {}".format(
                the_waiter.logs))
Beispiel #14
0
def compose_sub():
    resource('ska_mid/tm_subarray_node/1').assert_attribute('State').equals(
        'ON')
    resource('ska_mid/tm_subarray_node/1').assert_attribute('obsState').equals(
        'EMPTY')
    assign_resources_file = download_test_data(
        "mid_assign_resources_v1.json",
        "skampi-test-data/tmc-integration/assign-resources")
    sdp_block = update_resource_config_file(assign_resources_file)
    LOGGER.info("_______sdp_block________" + str(sdp_block))
    config = load_config_from_file(assign_resources_file)
    os.remove(assign_resources_file)
    CentralNode = DeviceProxy('ska_mid/tm_central/central_node')
    CentralNode.AssignResources(config)
    the_waiter = waiter()
    the_waiter.wait()
    LOGGER.info('Invoked AssignResources on CentralNode')
    return sdp_block
Beispiel #15
0
def restart_subarray(id):
    devices = device_to_subarrays.keys()
    filtered_devices = [
        device for device in devices if device_to_subarrays[device] == id
    ]
    the_waiter = waiter()
    the_waiter.set_wait_for_going_to_standby()
    exceptions_raised = ""
    LOGGER.info("Inside restart subarray method.")
    for device in filtered_devices:
        try:
            resource(device).restart()
            LOGGER.info("Restart subarray API invoked on device :" +
                        str(device))
        except Exception as e:
            exceptions_raised += f"\nException raised on reseting {device}:{e}"
    if exceptions_raised != "":
        raise Exception(f"Error in initialising devices:{exceptions_raised}")
    the_waiter.wait()
Beispiel #16
0
def set_telescope_to_standby():
    the_waiter = waiter()
    the_waiter.set_wait_for_going_to_standby()
    # TODO: Using TMC API for TelescopeOff command.
    # Telescope().standby()

    CentralNode = DeviceProxy("ska_mid/tm_central/central_node")
    CentralNode.TelescopeOff()
    LOGGER.info("After Standby CentralNode State:" +
                str(CentralNode.telescopeState))
    LOGGER.info("Standby the Telescope")

    # It is observed that CSP and CBF subarrays sometimes take more than 8 sec to change the State to DISABLE
    # therefore timeout is given as 12 sec
    the_waiter.wait(5000)
    if the_waiter.timed_out:
        pytest.fail(
            "timed out whilst setting telescope to standby:\n {}".format(
                the_waiter.logs))
Beispiel #17
0
def telescope_is_in_standby():
    the_waiter = waiter()
    the_waiter.wait(5000)
    LOGGER.info(
        'resource("ska_mid/tm_central/central_node").get("telescopeState")' +
        str(resource("ska_mid/tm_central/central_node").get("telescopeState")))
    LOGGER.info('resource("mid_csp/elt/subarray_01").get("State")' +
                str(resource("mid_csp/elt/subarray_01").get("State")))
    LOGGER.info('resource("mid_sdp/elt/subarray_1").get("State")' +
                str(resource("mid_sdp/elt/subarray_1").get("State")))
    LOGGER.info('resource("mid_csp/elt/master").get("State")' +
                str(resource("mid_csp/elt/master").get("State")))
    LOGGER.info('resource("mid_sdp/elt/master").get("State")' +
                str(resource("mid_sdp/elt/master").get("State")))

    LOGGER.info('resource("mid_d0001/elt/master").get("State")' +
                str(resource("mid_d0001/elt/master").get("State")))
    LOGGER.info('resource("mid_d0002/elt/master").get("State")' +
                str(resource("mid_d0002/elt/master").get("State")))
    LOGGER.info('resource("mid_d0003/elt/master").get("State")' +
                str(resource("mid_d0003/elt/master").get("State")))
    LOGGER.info('resource("mid_d0004/elt/master").get("State")' +
                str(resource("mid_d0004/elt/master").get("State")))
    return [
        resource("ska_mid/tm_central/central_node").get("telescopeState"),
        resource("mid_csp/elt/subarray_01").get("State"),
        resource("mid_sdp/elt/subarray_1").get("State"),
        resource("mid_csp/elt/master").get("State"),
        resource("mid_d0001/elt/master").get("State"),
        resource("mid_d0002/elt/master").get("State"),
        resource("mid_d0003/elt/master").get("State"),
        resource("mid_d0004/elt/master").get("State"),
    ] == [
        "STANDBY",
        "OFF",
        "OFF",
        "STANDBY",
        "STANDBY",
        "STANDBY",
        "STANDBY",
        "STANDBY",
    ]
Beispiel #18
0
def tmc_is_on():
    the_waiter = waiter()
    the_waiter.set_wait_for_tmc_starting_up()
    the_waiter.wait(5000)
    LOGGER.info('resource("ska_mid/tm_central/central_node").get("State")' +
                str(resource("ska_mid/tm_central/central_node").get("State")))

    LOGGER.info('resource("ska_mid/tm_subarray_node/1").get("State")' +
                str(resource("ska_mid/tm_subarray_node/1").get("State")))

    LOGGER.info('resource("ska_mid/tm_leaf_node/sdp_master").get("State")' +
                str(resource("ska_mid/tm_leaf_node/sdp_master").get("State")))

    LOGGER.info(
        'resource("ska_mid/tm_leaf_node/sdp_subarray01").get("State")' +
        str(resource("ska_mid/tm_leaf_node/sdp_subarray01").get("State")))
    LOGGER.info('resource("ska_mid/tm_leaf_node/csp_master").get("State")' +
                str(resource("ska_mid/tm_leaf_node/csp_master").get("State")))
    LOGGER.info(
        'resource("ska_mid/tm_leaf_node/csp_subarray01").get("State")' +
        str(resource("ska_mid/tm_leaf_node/csp_subarray01").get("State")))
    LOGGER.info('resource("ska_mid/tm_leaf_node/d0001").get("State")' +
                str(resource("ska_mid/tm_leaf_node/d0001").get("State")))
    LOGGER.info('resource("ska_mid/tm_leaf_node/d0002").get("State")' +
                str(resource("ska_mid/tm_leaf_node/d0002").get("State")))
    LOGGER.info('resource("ska_mid/tm_leaf_node/d0003").get("State")' +
                str(resource("ska_mid/tm_leaf_node/d0003").get("State")))
    LOGGER.info('resource("ska_mid/tm_leaf_node/d0004").get("State")' +
                str(resource("ska_mid/tm_leaf_node/d0004").get("State")))

    return [
        resource("ska_mid/tm_central/central_node").get("State"),
        resource("ska_mid/tm_subarray_node/1").get("State"),
        resource("ska_mid/tm_leaf_node/sdp_master").get("State"),
        resource("ska_mid/tm_leaf_node/sdp_subarray01").get("State"),
        resource("ska_mid/tm_leaf_node/csp_master").get("State"),
        resource("ska_mid/tm_leaf_node/csp_subarray01").get("State"),
        resource("ska_mid/tm_leaf_node/d0001").get("State"),
        resource("ska_mid/tm_leaf_node/d0002").get("State"),
        resource("ska_mid/tm_leaf_node/d0003").get("State"),
        resource("ska_mid/tm_leaf_node/d0004").get("State"),
    ] == ["ON", "ON", "ON", "ON", "ON", "ON", "ON", "ON", "ON", "ON"]
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")
Beispiel #20
0
def allocate_four_dishes(result):
    the_waiter = waiter()
    the_waiter.set_wait_for_assign_resources()

    result['response'] = SubArray(1).allocate(
        ResourceAllocation(dishes=[Dish(1), Dish(2),
                                   Dish(3), Dish(4)]))

    #wait for certain values to be changed (refer to helpers for what is currently defined as neccesarry to wait)
    the_waiter.wait()
    LOGGER.info(the_waiter.logs)
    result = wait_for(resource('mid_csp/elt/master'), 20).to_be({
        "attr":
        "receptorMembership",
        "value": (1, 1, 1, 1)
    })
    if (result == "timed out"):
        LOGGER.info(
            "timed out after 2 seconds waiting for mid_csp/elt/master receptorMembership to change to (1,1,1,1)"
        )

    return result
Beispiel #21
0
def teardown_function(function):
    """ teardown any state that was previously setup with a setup_function
    call.
    """
    the_waiter = waiter()
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "IDLE"):
        #this means there must have been an error
        the_waiter.set_wait_for_tearing_down_subarray()
        LOGGER.info("tearing down composed subarray (IDLE)")
        SubArray(1).deallocate()
        the_waiter.wait()
        LOGGER.info(the_waiter.logs)
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "READY"):
        #this means test must have passed
        LOGGER.info("tearing down configured subarray (READY)")
        the_waiter.set_wait_for_ending_SB()
        SubArray(1).end_sb()
        the_waiter.wait()
        LOGGER.debug(the_waiter.logs)
        the_waiter.set_wait_for_tearing_down_subarray()
        SubArray(1).deallocate()
        the_waiter.wait()
        LOGGER.debug(the_waiter.logs)
    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("Putting Telescope in standby")
    the_waiter.set_wait_for_going_to_standby()
    SKAMid().standby()
    the_waiter.wait()
    LOGGER.debug(the_waiter.logs)
Beispiel #22
0
def sync_going_to_standby(timeout=50):
    check_going_into_standby()
    the_waiter = waiter()
    the_waiter.set_wait_for_going_to_standby()
    yield
    the_waiter.wait(timeout)
Beispiel #23
0
def sync_resources_releasing(timeout=100):
    the_waiter = waiter()
    the_waiter.set_wait_for_tearing_down_subarray()
    yield
    the_waiter.wait(timeout)
def test_obsreset():
    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("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")
        sdp_block = tmc.compose_sub()
        fixture["state"] = "Subarray Assigned"

        @log_it("TMC_int_configure", devices_to_log,
                non_default_states_to_check)
        def configure_sub(sdp_block):
            # commented because below asserts are already checked in @sync_configure
            # resource('ska_mid/tm_subarray_node/1').assert_attribute('State').equals('ON')
            # resource('ska_mid/tm_subarray_node/1').assert_attribute('obsState').equals('IDLE')
            configure1_file = "resources/test_data/TMC_integration/configure2.json"
            update_scan_config_file(configure1_file, sdp_block)
            config = load_config_from_file(configure1_file)
            LOGGER.info("Configuring a scan for subarray 1")
            fixture["state"] = "Subarray CONFIGURING"
            SubarrayNode = DeviceProxy("ska_mid/tm_subarray_node/1")
            SubarrayNode.Configure(config)
            LOGGER.info("Invoked Configure on Subarray")

        configure_sub(sdp_block)
        fixture["state"] = "Subarray Configured for SCAN"

        resource("ska_mid/tm_subarray_node/1").assert_attribute(
            "obsState").equals("CONFIGURING")
        LOGGER.info("Aborting the subarray")
        fixture["state"] = "Subarray ABORTING"

        @log_it("TMC_int_abort", devices_to_log, non_default_states_to_check)
        @sync_abort()
        def abort():
            resource("ska_mid/tm_subarray_node/1").assert_attribute(
                "State").equals("ON")
            resource("ska_mid/tm_subarray_node/1").assert_attribute(
                "obsState").equals("CONFIGURING")
            SubarrayNode = DeviceProxy("ska_mid/tm_subarray_node/1")
            SubarrayNode.Abort()
            LOGGER.info("Invoked Abort on Subarray")

        abort()
        the_waiter.wait()

        LOGGER.info("Abort is complete on Subarray")
        fixture["state"] = "Subarray Aborted"

        fixture["state"] = "Subarray Resetting"

        @sync_obsreset()
        def obsreset():
            resource("ska_mid/tm_subarray_node/1").assert_attribute(
                "State").equals("ON")
            # resource('mid_csp/elt/subarray_01').assert_attribute('obsState').equals('ABORTED')
            # resource('mid_sdp/elt/subarray_1').assert_attribute('obsState').equals('ABORTED')
            SubarrayNode = DeviceProxy("ska_mid/tm_subarray_node/1")
            # the_waiter.wait()
            LOGGER.info(
                "Subarray obsState before Aborted assertion check is: " +
                str(SubarrayNode.obsState))
            resource("ska_mid/tm_subarray_node/1").assert_attribute(
                "obsState").equals("ABORTED")
            SubarrayNode.ObsReset()
            LOGGER.info("Subarray obsState is: " + str(SubarrayNode.obsState))
            LOGGER.info("Invoked obsreset on Subarray")

        obsreset()

        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")

        # tear down
        LOGGER.info("TMC-ObsReset 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":
            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")
Beispiel #25
0
def sync_sb_ending():
    check_going_out_of_configured()
    the_waiter = waiter()
    the_waiter.set_wait_for_ending_SB()
    yield
    the_waiter.wait()
Beispiel #26
0
def sync_telescope_starting_up(timeout=50):
    check_coming_out_of_standby()
    the_waiter = waiter()
    the_waiter.set_wait_for_starting_up()
    yield
    the_waiter.wait(timeout)
Beispiel #27
0
def sync_assigned_resources(nr_of_receptors=4):
    check_going_out_of_empty()
    the_waiter = waiter()
    the_waiter.set_wait_for_assign_resources(nr_of_receptors=nr_of_receptors)
    yield
    the_waiter.wait(timeout=60)
Beispiel #28
0
def test_multi_scan():

    ####
    try:
        the_waiter = waiter()
        fixture = {}
        fixture["state"] = "Unknown"

        # given a started up telescope
        LOGGER.info("Checking if Telescope is in StandBy")
        assert telescope_is_in_standby()
        LOGGER.info("Telescope is in StandBy")
        tmc.start_up()
        LOGGER.info("Staring up the Telescope")
        fixture["state"] = "Telescope On"

        # and a subarray composed of two resources configured as perTMC_integration/assign_resources1.json
        sdp_block = tmc.compose_sub()
        LOGGER.info("Composing the Subarray")
        fixture["state"] = "Subarray Assigned"

        # and for which the subarray is configured to perform a scan as per 'TMC_integration/configure1.json'
        fixture["state"] = "Subarray CONFIGURING"
        configure_file = "resources/test_data/TMC_integration/configure2.json"
        tmc.configure_sub(sdp_block, configure_file)
        LOGGER.info("Configuring the Subarray")
        fixture["state"] = "Subarray Configured for SCAN"

        # and for which the subarray has successfully completed a scan durating 6 seconds based on previos configuration
        resource("ska_mid/tm_subarray_node/1").assert_attribute("obsState").equals(
            "READY"
        )
        LOGGER.info("Starting a scan of 6 seconds")

        with log_states("TMC_ss-41-scan1", devices_to_log, non_default_states_to_check):
            with sync_scanning(200):
                SubarrayNode = DeviceProxy("ska_mid/tm_subarray_node/1")
                SubarrayNode.Scan('{"id":1}')
                fixture["state"] = "Subarray SCANNING"
                LOGGER.info("Subarray obsState is: " + str(SubarrayNode.obsState))
                LOGGER.info("Scan 1  is executing on Subarray")

        LOGGER.info("Scan1 complete")
        fixture["state"] = "Subarray Configured for SCAN"

        # then when I load a  new configuration to perform a can as per TMC_integration/configure2.json
        LOGGER.info("Configuring the Subarray")
        fixture["state"] = "Subarray CONFIGURING"
        configure_file = "resources/test_data/TMC_integration/configure1.json"
        tmc.configure_sub(sdp_block, configure_file)
        LOGGER.info("Configuring the Subarray")
        fixture["state"] = "Subarray Configured for SCAN"

        # and run a new scan bsed on that configuration
        resource("mid_csp/elt/subarray_01").assert_attribute("obsState").equals("READY")
        resource("mid_csp_cbf/sub_elt/subarray_01").assert_attribute("obsState").equals(
            "READY"
        )
        resource("mid_sdp/elt/subarray_1").assert_attribute("obsState").equals("READY")
        resource("ska_mid/tm_subarray_node/1").assert_attribute("obsState").equals(
            "READY"
        )
        LOGGER.info("Starting a scan of 6 seconds")

        with log_states("TMC_ss-41-scan2", devices_to_log, non_default_states_to_check):
            with sync_scanning(200):
                LOGGER.info("Check obsstate again before starting 2nd scan")
                resource("ska_mid/tm_subarray_node/1").assert_attribute(
                    "obsState"
                ).equals("READY")
                resource("mid_csp/elt/subarray_01").assert_attribute("obsState").equals(
                    "READY"
                )
                resource("mid_csp_cbf/sub_elt/subarray_01").assert_attribute(
                    "obsState"
                ).equals("READY")
                resource("mid_sdp/elt/subarray_1").assert_attribute("obsState").equals(
                    "READY"
                )

                SubarrayNode = DeviceProxy("ska_mid/tm_subarray_node/1")
                SubarrayNode.Scan('{"id":1}')
                fixture["state"] = "Subarray SCANNING"
                LOGGER.info("Subarray obsState is: " + str(SubarrayNode.obsState))
        LOGGER.info("Scan2 complete")
        fixture["state"] = "Subarray Configured for SCAN"

        # the scanning should complete without any exceptions
        # TODO possibly add some other asserts in here

        # tear down
        LOGGER.info("TMC-multiscan tests complete: tearing down...")
        tmc.end_sb()
        the_waiter.wait()
        LOGGER.info("Invoked EndSB on Subarray")
        tmc.release_resources()
        the_waiter.wait()
        LOGGER.info("Invoked ReleaseResources on Subarray")
        tmc.set_to_standby()
        LOGGER.info("Invoked StandBy on Subarray")
        the_waiter.wait()
        LOGGER.info("Invoked StandBy on Subarray")
        LOGGER.info("Tests complete: tearing down...")

    except Exception as e:
        logging.info(f"Exception raised: {e.args}")
        LOGGER.info("Gathering logs")
        LOGGER.info("Tearing down failed test, state = {}".format(fixture["state"]))
        if fixture["state"] == "Telescope On":
            tmc.set_to_standby()
            the_waiter.wait()
        elif fixture["state"] == "Subarray Assigned":
            tmc.release_resources()
            the_waiter.wait()
            tmc.set_to_standby()
            the_waiter.wait()
        elif fixture["state"] == "Subarray Configured for SCAN":
            tmc.end_sb()
            the_waiter.wait()
            tmc.release_resources()
            the_waiter.wait()
            tmc.set_to_standby()
            the_waiter.wait()
        elif fixture["state"] == "Subarray SCANNING":
            if resource("ska_mid/tm_subarray_node/1").get("obsState") == "SCANNING":
                raise Exception("unable to teardown subarray from being in SCANNING")
            else:
                # sleep arbitrary number here to handle possible failures in un-idempotentcy
                sleep(3)
                tmc.end_sb()
                the_waiter.wait()
                tmc.release_resources()
                the_waiter.wait()
                tmc.set_to_standby()
                the_waiter.wait()
                raise e
        elif fixture["state"] == "Subarray CONFIGURING":
            raise Exception("unable to teardown subarray from being in CONFIGURING")
        elif fixture["state"] == "Unknown":
            LOGGER.info("Put telescope back to standby")
            tmc.set_to_standby()
            the_waiter.wait()
        pytest.fail("unable to complete test without exceptions")
Beispiel #29
0
def sync_oet_scanning(timeout=200):
    check_going_out_of_configured()
    the_waiter = waiter()
    the_waiter.set_wait_for_going_into_scanning()
    yield
    the_waiter.wait()
Beispiel #30
0
def start_up():
    the_waiter = waiter()
    the_waiter.set_wait_for_starting_up()
    SKAMid().start_up()
    the_waiter.wait()
    LOGGER.info(the_waiter.logs)