Exemplo n.º 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")
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'))
Exemplo n.º 3
0
def configure_by_file():
    configure_file = 'resources/test_data/OET_integration/mccs_configure.json'
    SubarrayNodeLow = DeviceProxy('ska_low/tm_subarray_node/1')
    subarray = SubArray(1)
    LOGGER.info('Subarray has been created.')
    subarray.configure_from_file(configure_file, 10, with_processing=False)
    LOGGER.info("Subarray obsState is: " + str(SubarrayNodeLow.obsState))
    LOGGER.info('Invoked Configure on Subarray')
Exemplo n.º 4
0
def oet_compose_sub():
    cdm_file_path = 'resources/test_data/OET_integration/example_allocate.json'
    LOGGER.info("cdm_file_path :" + str(cdm_file_path))
    update_resource_config_file(cdm_file_path)
    cdm_request_object = cdm_CODEC.load_from_file(AssignResourcesRequest, cdm_file_path)
    cdm_request_object.dish.receptor_ids = [str(x).zfill(4) for x in range(1, 5)]
    subarray = SubArray(1)
    LOGGER.info("Allocated Subarray is :" + str(subarray))
    return subarray.allocate_from_cdm(cdm_request_object)
Exemplo n.º 5
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()
Exemplo n.º 6
0
 def __init__(self, id):
     self.SubArray = SubArray(id)
     self.logs = ""
     self.agents = ResourceGroup(resource_names=subarray_devices)
     self.state = "Empty"
     self.rollback_order = {
         'IDLE': self.reset_when_aborted
         #'Ready':self.and_end_sb_when_ready,
         # 'Configuring':restart_subarray,
         # 'Scanning':restart_subarray
     }
Exemplo n.º 7
0
 def __init__(self, id):
     self.SubArray = SubArray(id)
     self.logs = ""
     self.agents = ResourceGroup(resource_names=subarray_devices)
     self.state = "Empty"
     self.rollback_order = {
         "Composed": self.and_release_all_resources,
         "Ready": self.and_end_sb_when_ready,
         # 'Configuring':restart_subarray,
         # 'Scanning':restart_subarray
     }
Exemplo n.º 8
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')
Exemplo n.º 9
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")
Exemplo n.º 10
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")
Exemplo n.º 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")
Exemplo n.º 12
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()
Exemplo n.º 13
0
def do_scan(monkeypatch, configured_subarray: SubarrayContext,):
    """Monkeypatching the SCAN_ID_GENERATOR to ensure that the RemoteScanIdGenerator will
    be used"""
    monkeypatch.setattr(
        observingtasks,
        "SCAN_ID_GENERATOR",
        RemoteScanIdGenerator(os.environ["SKUID_URL"]),
        raising=True,
    )
    board = set_to_wait.set_waiting_for_scanning_to_complete(configured_subarray.id, configured_subarray.receptors)
    with wait.wait_for(board, timeout=60):
        SubArray(1).scan()
Exemplo n.º 14
0
class pilot():
    def __init__(self, id):
        self.SubArray = SubArray(id)
        self.logs = ""
        self.agents = ResourceGroup(resource_names=subarray_devices)
        self.state = "Empty"
        self.rollback_order = {
            'IDLE': self.reset_when_aborted
            #'Ready':self.and_end_sb_when_ready,
            # 'Configuring':restart_subarray,
            # 'Scanning':restart_subarray
        }

    def and_display_state(self):
        print("state at {} is:\n{}".format(datetime.now(),
                                           self.agents.get('State')))
        return self

    def and_display_obsState(self):
        print("state at {} is:\n{}".format(datetime.now(),
                                           self.agents.get('obsState')))
        return self

    def reset_when_aborted(self):
        @sync_reset_sa
        def reset():
            self.SubArray.reset()

        reset()
        self.state = "IDLE"
        return self

    def and_end_sb_when_ready(self):
        @sync_end_sb
        def end_sb():
            self.SubArray.end()

        end_sb()
        self.state = "Composed"
        return self
Exemplo n.º 15
0
 def send_scan(duration):
     # TODO: Update the api when new tmc-mid chart is published
     SubArray(1).scan()
Exemplo n.º 16
0
class pilot:
    def __init__(self, id):
        self.SubArray = SubArray(id)
        self.logs = ""
        self.agents = ResourceGroup(resource_names=subarray_devices)
        self.state = "Empty"
        self.rollback_order = {
            "Composed": self.and_release_all_resources,
            "Ready": self.and_end_sb_when_ready,
            # 'Configuring':restart_subarray,
            # 'Scanning':restart_subarray
        }

    def and_display_state(self):
        print("state at {} is:\n{}".format(datetime.now(),
                                           self.agents.get("State")))
        return self

    def and_display_obsState(self):
        print("state at {} is:\n{}".format(datetime.now(),
                                           self.agents.get("obsState")))
        return self

    ##the following methods are implemented versions of what gets tested
    ##unless a specic version  is tested they should be exactly the same

    def to_be_composed_out_of(
            self,
            dishes,
            file="resources/test_data/OET_integration/example_allocate.json"):
        ##Reference tests/acceptance/mvp/test_XR-13_A1.py
        @sync_assign_resources(dishes, 600)
        def assign():
            sdp_block = update_resource_config_file(file)
            resource_request: AssignResourcesRequest = cdm_CODEC.load_from_file(
                AssignResourcesRequest, file)
            resource_request.dish.receptor_ids = [
                str(x).zfill(4) for x in range(1, dishes + 1)
            ]
            self.SubArray.allocate_from_cdm(resource_request)
            return sdp_block

        sdp_block = assign()
        self.state = "Composed"
        LOGGER.info("_________Sdp block from composed function_______" +
                    str(self) + str(sdp_block))
        return self, sdp_block

    def and_configure_scan_by_file(
        self,
        sdp_block,
        file="resources/test_data/OET_integration/example_configure.json",
    ):
        ##Reference tests/acceptance/mvp/test_XR-13_A2-Test.py
        @sync_configure_oet
        @time_it(120)
        def config(file, sdp_block):
            update_scan_config_file(file, sdp_block)
            LOGGER.info("___________Input file in configure_oet_____________" +
                        str(file))
            self.state = "Configuring"
            self.SubArray.configure_from_file(file, 6, with_processing=False)

        LOGGER.info("___________SDP block from configure_oet_____________" +
                    str(sdp_block))
        config(file, sdp_block)
        self.state = "Ready"
        return self

    def and_run_a_scan(self):
        ##Reference tests/acceptance/mvp/test_XR-13_A3-Test.py
        ##note this is a different sync decorator as test since test performs the command as non blocking
        # @sync_scan_oet
        def scan():
            self.SubArray.scan()

        scan()
        self.state = "Ready"
        return self

    def and_release_all_resources(self):
        @sync_release_resources
        def de_allocate():
            self.SubArray.deallocate()

        de_allocate()
        self.state = "Empty"
        return self

    def and_end_sb_when_ready(self):
        @sync_end_sb
        def end_sb():
            self.SubArray.end()

        end_sb()
        self.state = "Composed"
        return self

    def restart_when_aborted(self):
        @sync_restart_sa
        def restart():
            self.SubArray.restart()

        restart()
        self.state = "EMPTY"
        return self

    def reset_when_aborted(self):
        @sync_reset_sa
        def reset():
            self.SubArray.reset()

        reset()
        self.state = "IDLE"
        return self

    def roll_back(self):
        if self.state != "Empty":
            self.rollback_order[self.state]()

    def reset(self):
        while self.state != "Empty":
            self.rollback_order[self.state]()
Exemplo n.º 17
0
 def scan():
     SubArray(1).scan()
Exemplo n.º 18
0
DEV_TEST_TOGGLE = os.environ.get('DISABLE_DEV_TESTS')
if DEV_TEST_TOGGLE == "False":
    DISABLE_TESTS_UNDER_DEVELOPMENT = False
else:
    DISABLE_TESTS_UNDER_DEVELOPMENT = True

LOGGER = logging.getLogger(__name__)

devices_to_log = [
    'ska_low/tm_subarray_node/1', 'low-mccs/control/control',
    'low-mccs/subarray/01'
]
non_default_states_to_check = {}

subarray = SubArray(1)


@pytest.fixture
def result():
    return {}


@pytest.mark.skalow
@pytest.mark.quarantine
@scenario("XTP-2398.feature",
          "BDD Test case for subarray Restart functionality")
def test_subarray_restart():
    """RESTART Subarray"""

Exemplo n.º 19
0
 def test_SUT(sdp_block):
     file = 'resources/test_data/OET_integration/configure1.json'
     update_scan_config_file(file, sdp_block)
     LOGGER.info("SDP block is :" + str(sdp_block))
     LOGGER.info("Invoking Configure command on Subarray 1")
     SubArray(1).configure_from_file(file, 6, with_processing=False)
Exemplo n.º 20
0
 def abort():
     LOGGER.info("Invoking ABORT command.")
     SubArray(1).abort()
     LOGGER.info("Abort command is invoked on subarray")
Exemplo n.º 21
0
 def send_scan(duration):
     SubArray(1).scan()
Exemplo n.º 22
0
 def command_restart():
     LOGGER.info("Invoking Restart command on the Subarray.")
     SubArray(1).restart()
     LOGGER.info("Restart command is invoked on subarray")
Exemplo n.º 23
0
 def obsreset_subarray():
     LOGGER.info("Invoking ObsReset command on the Subarray.")
     SubArray(1).reset()
     LOGGER.info("ObsReset command is invoked on subarray")