Beispiel #1
0
def set_subarray_to_fault(result):
    """
    Set sub-array to FAULT state by sending incomplete JSON in the Configure
    command.
    """
    LOGGER.info("Before starting the telescope checking if the TMC is in ON state")
    assert(tmc_is_on())
    if telescope_is_in_standby():
        set_telescope_to_running()
    take_subarray(1).to_be_composed_out_of(2)

    subarray = SubArray(1)

    conf_req = ConfigureRequest()
    conf_req.dish = DishConfiguration(receiver_band=ReceiverBand.BAND_1)

    # To set sub-array to FAULT, catch and ignore
    # the DevFailed of a bad Configure command
    try:
        subarray.configure_from_cdm(conf_req)
    except DevFailed:
        pass

    subarray_state = resource(result[SUBARRAY_USED]).get('obsState')
    assert subarray_state == 'FAULT', \
        f"Expected sub-array to be in FAULT but instead was in {subarray_state}"

    LOGGER.info("Sub-array has been set to FAULT")
Beispiel #2
0
def end(result):
    """ teardown any state that was previously setup for the tests.

    Args:
        result (dict): fixture to track test state
    """
    subarray = resource(result[SUBARRAY_USED])
    obsstate = subarray.get('obsState')
    LOGGER.info("CLEANUP: Sub-array in obsState %s ", obsstate)
    if obsstate == "IDLE":
        LOGGER.info("CLEANUP: tearing down composed subarray (IDLE)")
        take_subarray(1).and_release_all_resources()
    if obsstate == "READY":
        LOGGER.info("CLEANUP: tearing down configured subarray (READY)")
        take_subarray(1).and_end_sb_when_ready(
        ).and_release_all_resources()
    if subarray.get('obsState') != "EMPTY":
        LOGGER.warning(
            "Subarray is still in %s Please restart MVP manually to complete tear down",
            obsstate)
        restart_subarray(1)
        # 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 ",
                subarray.get('obsState'))
Beispiel #3
0
def set_to_ready():
    LOGGER.info("Allocate 2 dishes to Subarray 1")
    pilot, sdp_block = take_subarray(1).to_be_composed_out_of(2)
    LOGGER.info("AssignResources is successful on Subarray 1 with 2 dishes allocated")
    LOGGER.info("Invoking configure command on the Subarray.")
    take_subarray(1).and_configure_scan_by_file(sdp_block)
    LOGGER.info("Configure is successful on Subarray")
Beispiel #4
0
def configure_ready(sdp_block):
    LOGGER.info("Invoking configure command on the Subarray.")
    take_subarray(1).and_configure_scan_by_file(sdp_block)
    LOGGER.info("Configure command is invoked on Subarray.")
    LOGGER.info(
        "Subarray is moved to READY, Configure command is successful on Subarray."
    )
Beispiel #5
0
def end(result):
    """ teardown any state that was previously setup with a setup_function
    call.
    """
    LOGGER.info("End of test: Resetting Telescope")
    if resource('ska_mid/tm_subarray_node/1').get("obsState") == "IDLE":
        LOGGER.info("Release all resources assigned to subarray")
        take_subarray(1).and_release_all_resources()
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "READY"):
        LOGGER.info("tearing down configured subarray (READY)")
        take_subarray(1).and_end_sb_when_ready().and_release_all_resources()
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "CONFIGURING"
        ):
        LOGGER.warn(
            "Subarray is still in CONFIFURING! Please restart MVP manually 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")
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "SCANNING"):
        LOGGER.warn(
            "Subarray is still in SCANNING! Please restart MVP manually 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("Put Telescope back to standby")
    set_telescope_to_standby()
Beispiel #6
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"):
        #this means there must have been an error
        if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "IDLE"):
            LOGGER.info("tearing down composed subarray (IDLE)")
            take_subarray(1).and_release_all_resources()
    if (resource('ska_mid/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().and_release_all_resources()
        LOGGER.info("EndSb and ReleaseResources is involked on Subarray 1")
    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("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 with a setup_function
    call.
    """
    obsstate = resource(result[SUBARRAY_USED]).get('obsState')
    if obsstate == "IDLE":
        LOGGER.info("CLEANUP: tearing down composed subarray (IDLE)")
        take_subarray(1).and_release_all_resources()
    set_telescope_to_standby()
Beispiel #8
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("obsState") == "IDLE"):
        LOGGER.info("Release all resources assigned to subarray")
        take_subarray(1).and_release_all_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")
Beispiel #9
0
def setup_telescope_and_scan(result):
    """
    confirm the telescope is ready, and then to be sure we are testing a multiscan scenario
    perform one scan
    """
    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()
    LOGGER.info("Telescope is in StandBy.")
    LOGGER.info("Starting up telescope")
    set_telescope_to_running()
    LOGGER.info("Telescope is in running state.")
    LOGGER.info("Ensuring resources are assigned")
    result[SUBARRAY_USED], result['sdp_block'] = take_subarray(
        1).to_be_composed_out_of(2)
    LOGGER.info("Result of Subarray command is :" +
                str(result[SUBARRAY_USED]) + str(result['sdp_block']))
    LOGGER.info("Resources are assigned successfully on Subarray Node.")
    LOGGER.info("Invoking configure command on the Subarray for first Scan.")
    result[SUBARRAY_USED].and_configure_scan_by_file(
        result['sdp_block'],
        file='resources/test_data/OET_integration/example_configure.json',
    )
    LOGGER.info("Configure is successful on Subarray.")
    LOGGER.info("Invoking first scan on Subarray.")
    result[SUBARRAY_USED].and_run_a_scan()
    LOGGER.info("first scan completed on Subarray.")
    time.sleep(5)
    return result
Beispiel #10
0
def assign(result):
    LOGGER.info("Allocate 2 dishes to Subarray 1")
    pilot, sdp_block = take_subarray(1).to_be_composed_out_of(2)
    result['sdp_block'] = sdp_block
    LOGGER.info("Subarray 1 is ready and composed out of 2 dishes")
    LOGGER.info("SDP block in AssignResources json input is :" + str(result))
    return result
def set_subarray_to_idle(result):
    """
    Set sub-array to idle state after resources are allocated.
    """
    LOGGER.info(
        "Before starting the telescope checking if the TMC is in ON state")
    assert (tmc_is_on())
    if telescope_is_in_standby():
        LOGGER.info("Starting up telescope")
        set_telescope_to_running()
    LOGGER.info("Assigning 2 dishes")
    take_subarray(1).to_be_composed_out_of(2)
    subarray_state = resource(result[SUBARRAY_USED]).get('obsState')
    assert subarray_state == 'IDLE', \
        f"Expected sub-array to be in IDLE but instead was in {subarray_state}"
    LOGGER.info("Sub-array is in ObsState IDLE")
Beispiel #12
0
def start_script_execution(script, sb_json, result):
    """
    """
    LOGGER.info("Before starting the telescope checking if the TMC is in ON state")
    assert(tmc_is_on())
    if telescope_is_in_standby():
        set_telescope_to_running()
    take_subarray(1).to_be_composed_out_of(2)

    _ = EXECUTOR.create_script(script)
    task = EXECUTOR.start_script(sb_json)

    result[SCRIPT_ID] = task.task_id

    assert task.state == 'RUNNING', \
        f"Expected script to be RUNNING, instead was {task.state}"
Beispiel #13
0
def allocate_resources():
    """
    setting up running telescope with 2 dishes are allocated
    """
    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"
    )
    if telescope_is_in_standby():
        LOGGER.info("Starting up telescope")
        set_telescope_to_running()
        LOGGER.info("Telescope started")
    LOGGER.info("Assigning 2 dishes to subarray 1")
    take_subarray(1).to_be_composed_out_of(2)
    LOGGER.info("Resources are successfully assigned to subarray 1.")
Beispiel #14
0
def set_subarray_to_aborted(result):
    """
    Set sub-array to ABORTED state by sending Abort command after resources
    are allocated.
    """
    LOGGER.info("Before starting the telescope checking if the TMC is in ON state")
    assert(tmc_is_on())
    if telescope_is_in_standby():
        set_telescope_to_running()
    take_subarray(1).to_be_composed_out_of(2)

    subarray = SubArray(1)
    subarray.abort()

    subarray_state = resource(result[SUBARRAY_USED]).get('obsState')
    assert subarray_state == 'ABORTED', \
        f"Expected sub-array to be in ABORTED but instead was in {subarray_state}"

    LOGGER.info("Sub-array has been set to ABORTED")
Beispiel #15
0
def end(result):
    """ teardown any state that was previously setup with a setup_function
    call.
    """
    obsstate = resource(result[SUBARRAY_USED]).get('obsState')
    LOGGER.info("CLEANUP: Sub-array in obsState %s ", obsstate)
    if obsstate == "IDLE":
        LOGGER.info("CLEANUP: tearing down composed sub-array (IDLE)")
        take_subarray(1).and_release_all_resources()
    if obsstate == "ABORTED":
        LOGGER.info("CLEANUP: restarting aborted sub-array")
        sub = SubArray(1)
        sub.restart()
    if obsstate in ["RESOURCING", "RESTARTING", "RESETTING", "ABORTING"]:
        LOGGER.warning(
            "Subarray is still in %s Please restart MVP manually to complete tear down",
            obsstate)
        raise Exception("Unable to tear down test setup")
    set_telescope_to_standby()
Beispiel #16
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"):
        if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "IDLE"):
            LOGGER.info("tearing down composed subarray (IDLE)")
            take_subarray(1).and_release_all_resources()
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "CONFIGURING"
        ):
        LOGGER.warn(
            "Subarray is still in CONFIFURING! Please restart MVP manually to complete tear down"
        )
        restart_subarray(1)
        raise Exception("Unable to tear down test setup")
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "READY"):
        LOGGER.info("tearing down configured subarray (READY)")
        take_subarray(1).and_end_sb_when_ready().and_release_all_resources()
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "ABORTING"):
        LOGGER.warn(
            "Subarray is still in ABORTING! Please restart MVP manually to complete tear down"
        )
        restart_subarray(1)
        raise Exception("Unable to tear down test setup")
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "SCANNING"):
        LOGGER.warn(
            "Subarray is still in SCANNING! Please restart MVP manually to complete tear down"
        )
        restart_subarray(1)
        raise Exception("Unable to tear down test setup")
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "RESTARTING"
        ):
        LOGGER.warn(
            "Subarray is still in RESTARTING! Please restart MVP manually to complete tear down"
        )
        restart_subarray(1)
        raise Exception("Unable to tear down test setup")
    if (resource('ska_mid/tm_subarray_node/1').get('obsState') == "EMPTY"):
        LOGGER.info("Subarray is in EMPTY state.")
    LOGGER.info("Put Telescope back to standby")
    set_telescope_to_standby()
    LOGGER.info("Telescope is in standby")
Beispiel #17
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":
        if resource("ska_mid/tm_subarray_node/1").get("obsState") == "IDLE":
            LOGGER.info("tearing down composed subarray (IDLE)")
            take_subarray(1).and_release_all_resources()
            LOGGER.info(
                "Resources are deallocated successfully from Subarray.")
    if resource("ska_mid/tm_subarray_node/1").get("obsState") == "CONFIGURING":
        LOGGER.warn(
            "Subarray is still in CONFIFURING! Please restart MVP manually to complete tear down"
        )
        restart_subarray(1)
        raise Exception("Unable to tear down test setup")
    if resource("ska_mid/tm_subarray_node/1").get("obsState") == "READY":
        LOGGER.info("tearing down configured subarray (READY)")
        take_subarray(1).and_end_sb_when_ready().and_release_all_resources()
    if resource("ska_mid/tm_subarray_node/1").get("obsState") == "SCANNING":
        LOGGER.warn(
            "Subarray is still in SCANNING! Please restart MVP manually to complete tear down"
        )
        restart_subarray(1)
        raise Exception("Unable to tear down test setup")
    if resource("ska_mid/tm_subarray_node/1").get("obsState") == "ABORTING":
        LOGGER.warn(
            "Subarray is still in ABORTING! Please restart MVP manually to complete tear down"
        )
        restart_subarray(1)
    if resource("ska_mid/tm_subarray_node/1").get("obsState") == "ABORTED":
        take_subarray(1).restart_when_aborted()
    LOGGER.info("Put Telescope back to standby")
    set_telescope_to_standby()
    LOGGER.info("Telescope is in StandBy.")
Beispiel #18
0
def assign():
    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()
    LOGGER.info("Telescope is in StandBy.")
    LOGGER.info("Invoking Startup Telescope command on the telescope.")
    set_telescope_to_running()
    LOGGER.info("Telescope is started successfully.")
    pilot, sdp_block = take_subarray(1).to_be_composed_out_of(2)
    LOGGER.info("Resources are assigned successfully on Subarray.")
    return sdp_block