Beispiel #1
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 #2
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 #3
0
def start_up():
    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 the telescope")
    set_telescope_to_running()
    LOGGER.info("Telescope started.")
Beispiel #4
0
def start_up_telescope(result):
    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("PROCESS: Starting up telescope")
        set_telescope_to_running()

    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")
Beispiel #5
0
def set_to_running():
    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.")
def set_telescope_in_on_state(result):
    """
    Set telescope to ON state (startup) if it's not yet ON.
    """
    LOGGER.info(
        "Before starting the telescope checking if the TMC is in ON state")
    assert (tmc_is_on())
    LOGGER.info("Starting up telescope")
    if telescope_is_in_standby():
        set_telescope_to_running()
    telescope_state = resource(result[CENTRAL_NODE_USED]).get('telescopeState')
    assert telescope_state == 'ON', \
        f"Expected telescope to be ON but instead was {telescope_state}"
    LOGGER.info("Telescope is in ON state")
Beispiel #7
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
Beispiel #8
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}"
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 #10
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 #11
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 #12
0
def allocate_resources_from_sbi(script, sb_json):
    """
    Use the OET Rest API to run resource allocation script with SB JSON

    Args:
        script (str): file path to an observing script
        sb_json (str): file path to a scheduling block
    """
    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()

    script_completion_state = EXECUTOR.execute_script(
        script,
        sb_json,
        timeout=300
    )
    assert script_completion_state == 'COMPLETED', \
        f"Expected resource allocation script to be COMPLETED, instead was {script_completion_state}"
Beispiel #13
0
def test_tm_subarray_inconsistent_at_start_up():
    try:
        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.")

        resource('ska_mid/tm_central/central_node').assert_attribute(
            'telescopeState').equals('ON')
        #teardown
    finally:
        if not telescope_is_in_standby():
            set_telescope_to_standby()
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")