Ejemplo n.º 1
0
def check_going_into_empty():
    ## Can only release resources if subarray is in State ON and obsState IDLE
    logging.info("Check if the SubarrayNode State is ON and obsState is IDLE")
    resource("ska_low/tm_subarray_node/1").assert_attribute("State").equals(
        "ON")
    resource("ska_low/tm_subarray_node/1").assert_attribute("obsState").equals(
        "IDLE")
Ejemplo n.º 2
0
def restart():
    resource("ska_low/tm_subarray_node/1").assert_attribute("obsState").equals(
        "ABORTED")
    SubarrayNode = DeviceProxy("ska_low/tm_subarray_node/1")
    SubarrayNode.Restart()
    LOGGER.info("Subarray obsState is: " + str(SubarrayNode.obsState))
    LOGGER.info("Invoked restart on Subarray")
Ejemplo n.º 3
0
def obsreset():
    resource('ska_low/tm_subarray_node/1').assert_attribute('obsState').equals(
        'ABORTED')
    SubarrayNodeLow = DeviceProxy('ska_low/tm_subarray_node/1')
    SubarrayNodeLow.ObsReset()
    LOGGER.info("Subarray obsState is: " + str(SubarrayNodeLow.obsState))
    LOGGER.info('Invoked ObsReset command on Subarray')
Ejemplo n.º 4
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")
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'))
Ejemplo n.º 6
0
def end():
    resource("ska_low/tm_subarray_node/1").assert_attribute("obsState").equals("READY")
    resource("low-mccs/subarray/01").assert_attribute("obsState").equals("READY")
    LOGGER.info("Before invoking End Command all the devices obsstate is ready")
    SubarrayNodeLow = DeviceProxy("ska_low/tm_subarray_node/1")
    SubarrayNodeLow.End()
    LOGGER.info("Invoked End on Subarray")
Ejemplo n.º 7
0
def check_going_into_empty():
    ##Can only release resources if subarray is in ON/IDLE
    resource("ska_low/tm_subarray_node/1").assert_attribute("State").equals(
        "ON")
    logging.info("In check_going_into_empty")
    resource("ska_low/tm_subarray_node/1").assert_attribute("obsState").equals(
        "IDLE")
Ejemplo n.º 8
0
def obsreset():
    resource("ska_low/tm_subarray_node/1").assert_attribute("obsState").equals(
        "ABORTED"
    )
    SubarrayNodeLow = DeviceProxy("ska_low/tm_subarray_node/1")
    SubarrayNodeLow.ObsReset()
    LOGGER.info("Subarray obsState is: " + str(SubarrayNodeLow.obsState))
    LOGGER.info("Invoked ObsReset command on Subarray")
Ejemplo n.º 9
0
def telescope_is_in_standby():
    LOGGER.info('resource("ska_low/tm_subarray_node/1").get("State")' +
                str(resource('ska_low/tm_subarray_node/1').get("State")))
    LOGGER.info('resource("ska_low/tm_leaf_node/mccs_master").get("State")' +
                str(resource('ska_low/tm_leaf_node/mccs_master').get("State")))
    return  [resource('ska_low/tm_subarray_node/1').get("State"),
            resource('ska_low/tm_leaf_node/mccs_master').get("State")] == \
            ['OFF','OFF']
Ejemplo n.º 10
0
def check_state():
    LOGGER.info("Checking the results")
    # check that the TMC and MCCS report subarray as being in the obsState = ABORTED
    assert_that(resource('ska_low/tm_subarray_node/1').get(
        'obsState')).is_equal_to('ABORTED')
    assert_that(resource('low-mccs/subarray/01').get('obsState')).is_equal_to(
        'ABORTED')
    LOGGER.info("Results OK")
Ejemplo n.º 11
0
def end():
    resource('ska_low/tm_subarray_node/1').assert_attribute('obsState').equals(
        'READY')
    resource('low-mccs/subarray/01').assert_attribute('obsState').equals(
        'READY')
    LOGGER.info(
        'Before invoking End Command all the devices obsstate is ready')
    SubarrayNodeLow = DeviceProxy('ska_low/tm_subarray_node/1')
    SubarrayNodeLow.End()
    LOGGER.info('Invoked End on Subarray')
 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")
Ejemplo n.º 13
0
def to_be_composed_out_of():
    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/OET_integration/mccs_assign_resources.json'
    subarray = SubArray(1)
    LOGGER.info('Subarray has been created.')
    subarray.allocate_from_file(cdm_file=assign_resources_file,
                                with_processing=False)
    LOGGER.info('Invoked AssignResources on CentralNodeLow')
Ejemplo n.º 14
0
def set_telescope_to_running(disable_waiting=False):
    resource('ska_low/tm_subarray_node/1').assert_attribute('State').equals(
        'OFF')
    the_waiter = waiter()
    the_waiter.set_wait_for_starting_up()
    Telescope().start_up()
    if not disable_waiting:
        the_waiter.wait(100)
        if the_waiter.timed_out:
            pytest.fail("timed out whilst starting up telescope:\n {}".format(
                the_waiter.logs))
Ejemplo n.º 15
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)")
            # subarray.end()
            take_subarray(1).and_end_sb_when_ready()
            resource('ska_low/tm_subarray_node/1').assert_attribute('obsState').equals('IDLE')
            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")
        if (resource('ska_low/tm_subarray_node/1').get('obsState') == "ABORTING"):
            LOGGER.warn("Subarray is still in ABORTING! Please restart MVP Low 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') == "ABORTED"):
            LOGGER.info("tearing down configured subarray (ABORTED)")
            take_subarray(1).reset_when_aborted()
            LOGGER.info('Invoked ObsReset 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') == "RESETTING"):
            LOGGER.warn("Subarray is still in RESTARTING! 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") 
        set_telescope_to_standby()
        LOGGER.info("Telescope is in standBy")
Ejemplo n.º 16
0
def check_scanning_state(fixture):
    # check that the TMC report subarray as being in the obsState = SCANNING
    logging.info("TMC subarray low obsState: " +
                 resource('ska_low/tm_subarray_node/1').get("obsState"))
    assert_that(resource('ska_low/tm_subarray_node/1').get(
        'obsState')).is_equal_to('SCANNING')
    # check that the MCCS report subarray as being in the obsState = SCANNING
    logging.info("MCCS subarray low obsState: " +
                 resource('low-mccs/subarray/01').get("obsState"))
    assert_that(resource('low-mccs/subarray/01').get('obsState')).is_equal_to(
        'SCANNING')
    return fixture
Ejemplo n.º 17
0
def to_be_composed_out_of():
    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/OET_integration/mccs_assign_resources.json")
    subarray = SubArray(1)
    LOGGER.info("Subarray has been created.")
    subarray.allocate_from_file(cdm_file=assign_resources_file,
                                with_processing=False)
    LOGGER.info("Invoked AssignResources on CentralNodeLow")
Ejemplo n.º 18
0
 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")
Ejemplo n.º 19
0
def set_telescope_to_standby():
    resource('ska_low/tm_subarray_node/1').assert_attribute('State').equals(
        'ON')
    the_waiter = waiter()
    the_waiter.set_wait_for_going_to_standby()
    Telescope().standby()
    #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(100)
    if the_waiter.timed_out:
        pytest.fail(
            "timed out whilst setting telescope to standby:\n {}".format(
                the_waiter.logs))
Ejemplo n.º 20
0
def check_ready_state(fixture):
    fixture['future'].result(timeout=10)
    wait_before_test(timeout=10)
    # check that the TMC report subarray as being in the obsState = READY
    logging.info("TMC subarray low obsState: " +
                 resource('ska_low/tm_subarray_node/1').get("obsState"))
    assert_that(resource('ska_low/tm_subarray_node/1').get(
        'obsState')).is_equal_to('READY')
    # check that the MCCS report subarray as being in the obsState = READY
    logging.info("MCCS subarray low obsState: " +
                 resource('low-mccs/subarray/01').get("obsState"))
    assert_that(
        resource('low-mccs/subarray/01').get('obsState')).is_equal_to('READY')
Ejemplo n.º 21
0
def check_subarry_state():
    #check that the TMC report SubarrayLow as being in the ON state and obsState = IDLE
    assert_that(
        resource('ska_low/tm_subarray_node/1').get("State")).is_equal_to("ON")
    assert_that(resource('ska_low/tm_subarray_node/1').get(
        'obsState')).is_equal_to('IDLE')
    #check that the MCCS report subarray as being in the ON state and obsState = IDLE
    assert_that(
        resource('low-mccs/subarray/01').get('State')).is_equal_to('ON')
    assert_that(
        resource('low-mccs/subarray/01').get('obsState')).is_equal_to('IDLE')
    LOGGER.info(
        "Then the subarray is in the condition that allows scan configurations to take place: PASSED"
    )
Ejemplo n.º 22
0
def telescope_is_in_standby():
    LOGGER.info('resource("ska_low/tm_subarray_node/1").get("State")' +
                str(resource("ska_low/tm_subarray_node/1").get("State")))
    LOGGER.info('resource("ska_low/tm_leaf_node/mccs_master").get("State")' +
                str(resource("ska_low/tm_leaf_node/mccs_master").get("State")))
    # LOGGER.info(
    #     'resource("low-mccs/control/control").get("State")'
    #     + str(resource("low-mccs/control/control").get("State"))
    # )
    return [
        resource("ska_low/tm_subarray_node/1").get("State"),
        resource("ska_low/tm_leaf_node/mccs_master").get("State"),
        #resource("low-mccs/control/control").get("State"),
    ] == ["OFF", "OFF"]
Ejemplo n.º 23
0
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 = download_test_data(
        "low_assign_resources_v1.json",
        "skampi-test-data/tmc-integration/assign-resources",
    )
    config = load_config_from_file(assign_resources_file)
    os.remove(assign_resources_file)
    CentralNodeLow = DeviceProxy("ska_low/tm_central/central_node")
    CentralNodeLow.AssignResources(config)
    the_waiter = waiter()
    the_waiter.wait()
    LOGGER.info("Invoked AssignResources on CentralNodeLow")
Ejemplo n.º 24
0
def release_resources():
    resource("ska_low/tm_subarray_node/1").assert_attribute("obsState").equals(
        "IDLE")
    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)
    SubarrayNodeLow = DeviceProxy("ska_low/tm_subarray_node/1")
    LOGGER.info(
        "After Invoking Release Resource on Subarray, SubarrayNodeLow State and ObsState:"
        + str(SubarrayNodeLow.State()) + str(SubarrayNodeLow.ObsState))
    the_waiter = waiter()
    the_waiter.wait()
    LOGGER.info("finished ReleaseResources on CentralNodeLow")
Ejemplo n.º 25
0
def test_smell_mvp(pre_or_post="#PRE"):

    header = f"\n###{pre_or_post}-TEST STATES###\n{'Device Name:':<34} {'State':<15}{'obsState':<15}\n"
    output = [
        f"{device:<35}{resource(device).get('State'):<15}{resource(device).get('obsState'):<15}"
        for device in subarray_devices
    ]
    aggegate_output = reduce(lambda x, y: x + "\n" + y, output)
    LOGGER.info(f"Current state of the MVP LOW:{header+aggegate_output}")

    assert_that(
        resource("ska_low/tm_subarray_node/1").get("State")).is_equal_to(
            resource("ska_low/tm_subarray_node/1").get("State"))
    assert_that(resource("low-mccs/subarray/01").get("State")).is_equal_to(
        resource("low-mccs/subarray/01").get("State"))
Ejemplo n.º 26
0
def set_up_telescope(subarray_obsstate: str):
    if subarray_obsstate == "IDLE":
        assign()
        LOGGER.info(
            "Abort command can be invoked on Subarray with Subarray obsState as 'IDLE'"
        )
    elif subarray_obsstate == 'READY':
        assign()
        config()
        LOGGER.info(
            "Abort command can be invoked on Subarray with Subarray obsState as 'READY'"
        )
    elif subarray_obsstate == "SCANNING":
        assign()
        config()

        @sync_scanning_oet
        def scan():
            scan_file = 'resources/test_data/TMC_integration/mccs_scan.json'
            scan_string = load_config_from_file(scan_file)
            SubarrayNodeLow = DeviceProxy('ska_low/tm_subarray_node/1')
            SubarrayNodeLow.Scan(scan_string)
            # subarray.scan()
            LOGGER.info("scan command is called")

        scan()
        LOGGER.info("Subarray OBSSTATE '%s'",
                    resource('ska_low/tm_subarray_node/1').get('obsState'))
        LOGGER.info(
            "Abort command can be invoked on Subarray with Subarray obsState as 'SCANNING'"
        )
    else:
        msg = "obsState {} is not settable with command methods"
        raise ValueError(msg.format(subarray_obsstate))
Ejemplo n.º 27
0
def restart_subarray_low(id):
    devices = device_to_subarray.keys()
    filtered_devices = [
        device for device in devices if device_to_subarray[device] == id
    ]
    the_waiter = waiter()
    the_waiter.set_wait_for_going_to_standby()
    exceptions_raised = ""
    for device in filtered_devices:
        try:
            resource(device).restart()
        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()
Ejemplo n.º 28
0
def release_resources():
    resource('ska_low/tm_subarray_node/1').assert_attribute('obsState').equals(
        'IDLE')
    CentralNodeLow = DeviceProxy('ska_low/tm_central/central_node')
    release_resources_file = download_test_data(
        "mccs_release_resources_v1.json",
        "skampi-test-data/tmc-integration/release-resources")
    release_json = load_config_from_file(release_resources_file)
    os.remove(release_resources_file)
    CentralNodeLow.ReleaseResources(release_json)
    SubarrayNodeLow = DeviceProxy('ska_low/tm_subarray_node/1')
    LOGGER.info(
        'After Invoking Release Resource on Subarray, SubarrayNodeLow State and ObsState:'
        + str(SubarrayNodeLow.State()) + str(SubarrayNodeLow.ObsState))
    the_waiter = waiter()
    the_waiter.wait()
    LOGGER.info('finished ReleaseResources on CentralNodeLow')
def start_up_telescope(result):
    if telescope_is_in_standby():
        LOGGER.info("PROCESS: Starting up telescope")
        set_telescope_to_running()
        wait_before_test(timeout=10)

    subarray_state = resource(result[SUBARRAY_USED]).get('obsState')
    assert subarray_state == 'EMPTY', \
        f"Expected sub-array to be in EMPTY but instead was in {subarray_state}"
    LOGGER.info("Sub-array is in ObsState EMPTY")
Ejemplo n.º 30
0
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()