From 9a1b95cc7ab206257671720cef1ddd6d06b40cf9 Mon Sep 17 00:00:00 2001 From: GianlucaMarotta Date: Tue, 19 Jan 2021 12:13:58 +0100 Subject: [PATCH 01/10] CT-207 First changes in OffCommand --- csp-lmc-common/csp_lmc_common/CspSubarray.py | 51 ++++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/csp-lmc-common/csp_lmc_common/CspSubarray.py b/csp-lmc-common/csp_lmc_common/CspSubarray.py index 3e0f3a8..f1b3022 100644 --- a/csp-lmc-common/csp_lmc_common/CspSubarray.py +++ b/csp-lmc-common/csp_lmc_common/CspSubarray.py @@ -349,15 +349,25 @@ class CspSubarray(SKASubarray): class OffCommand(SKASubarray.OffCommand): def do(self): + self.results = None + self.logger.info("Call Off Command") device = self.target for fqdn in device._sc_subarray_fqdn: + try: # check if the sub-element subarray is already in the # requested state if device._sc_subarray_state[fqdn] == tango.DevState.OFF: continue - (result_code, message) = device._sc_subarray_proxies[fqdn].Off() + + if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + device._command_thread['offsequenze'] = threading.Thread(target=self.off_sequence, + name="Thread-OffSequence", + args=(fqdn,self.results)) + + (result_code, message) = self.results + if result_code == ResultCode.FAILED: self.logger.error("Off command failed on device {}".format(fqdn)) if fqdn != device.CbfSubarray: @@ -365,12 +375,45 @@ class CspSubarray(SKASubarray): continue else: return (ResultCode.FAILED, message) + + message = "Off command completed OK" + self.logger.info(message) + return (ResultCode.OK, message) + except tango.DevFailed as tango_err: message = str(tango_err.args[0].desc) return (ResultCode.FAILED, message) - message = "Off command completed OK" - self.logger.info(message) - return (ResultCode.OK, message) + + def off_sequence(self, fqdn): + device = self.target + starting_time = time.time() + timeout = device._sc_subarray_cmd_duration_expected[fqdn]['off'] + while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + try: + device._sc_subarray_proxies[fqdn].Abort() + while device._sc_subarray_obs_state is not ObsState.ABORTED: + if device._sc_subarray_obs_state==ObsState.FAULT: + break + pass + except ska.base.commands.CommandError: + pass + try: + device._sc_subarray_obs_state[fqdn].Restart() + except ska.base.commands.CommandError: + pass + + time.sleep(0.1) + + #IF SUCCESS + if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + self.results = device._sc_subarray_proxies[fqdn].Off() + # comando succeded. + + #IF TIMEOUT + if (time.time() - starting_time) > timeout: + + + class AssignResourcesCommand(SKASubarray.AssignResourcesCommand): -- GitLab From 1dce9bc7ddf355c844570b40e3e3b91f4274bdbb Mon Sep 17 00:00:00 2001 From: GianlucaMarotta Date: Thu, 21 Jan 2021 17:02:43 +0100 Subject: [PATCH 02/10] CSP-207 Changes in OffCommand --- csp-lmc-common/csp_lmc_common/CspSubarray.py | 78 ++++++++++++-------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/csp-lmc-common/csp_lmc_common/CspSubarray.py b/csp-lmc-common/csp_lmc_common/CspSubarray.py index e6ef188..65c6ab4 100644 --- a/csp-lmc-common/csp_lmc_common/CspSubarray.py +++ b/csp-lmc-common/csp_lmc_common/CspSubarray.py @@ -349,24 +349,41 @@ class CspSubarray(SKASubarray): class OffCommand(SKASubarray.OffCommand): def do(self): - self.results = None - self.logger.info("Call Off Command") device = self.target + subelement_thr = {} for fqdn in device._sc_subarray_fqdn: - try: - # check if the sub-element subarray is already in the - # requested state - if device._sc_subarray_state[fqdn] == tango.DevState.OFF: - continue + # check if the sub-element subarray is already in the + # requested state + if device._sc_subarray_state[fqdn] == tango.DevState.OFF: + continue - if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: - device._command_thread['offsequenze'] = threading.Thread(target=self.off_sequence, - name="Thread-OffSequence", - args=(fqdn,self.results)) + if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, + name="Thread-OffSequence", + args=(fqdn,)) + subelement_thr[fqdn].start() + + for fqdn in subelement_thr.keys(): + subelement_thr[fqdn].join() + + + if fqdn != device.CbfSubarray: + device._health_state = HealthState.DEGRADED + continue + else: + return (ResultCode.FAILED, message) + + + + + + try: + except tango.DevFailed as tango_err: + message = str(tango_err.args[0].desc) + return (ResultCode.FAILED, message) - (result_code, message) = self.results if result_code == ResultCode.FAILED: self.logger.error("Off command failed on device {}".format(fqdn)) @@ -380,38 +397,35 @@ class CspSubarray(SKASubarray): self.logger.info(message) return (ResultCode.OK, message) - except tango.DevFailed as tango_err: - message = str(tango_err.args[0].desc) - return (ResultCode.FAILED, message) + def off_sequence(self, fqdn): + #Off command send the device in the state:OFF, ObsState:EMPTY device = self.target starting_time = time.time() timeout = device._sc_subarray_cmd_duration_expected[fqdn]['off'] while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + # Try to send Abort Command. + # Device goes to ABORTED in case ObsState is: IDLE, READY, CONFIGURING, SCANNING, RESETTING try: + self.logger.info('Try to execute Abort command') device._sc_subarray_proxies[fqdn].Abort() - while device._sc_subarray_obs_state is not ObsState.ABORTED: - if device._sc_subarray_obs_state==ObsState.FAULT: + while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.ABORTED: + if device._sc_subarray_obs_state[fqdn]==ObsState.FAULT: break - pass - except ska.base.commands.CommandError: - pass + time.sleep(0.1) + except ska.base.commands.CommandError as msg: + self.logger.info(msg) + # Try to send Restart Command. + # Device goes to EMPTY if ObsState is: FAULT, ABORTED + # ObsState could be aborted from above try section try: + self.logger.info('Try to execute Restart command') device._sc_subarray_obs_state[fqdn].Restart() - except ska.base.commands.CommandError: - pass - + except ska.base.commands.CommandError as msg: + self.logger.info(msg) time.sleep(0.1) - - #IF SUCCESS - if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: - self.results = device._sc_subarray_proxies[fqdn].Off() - # comando succeded. - - #IF TIMEOUT - if (time.time() - starting_time) > timeout: - + # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition -- GitLab From 06ff3aea19d9d79e25c8527cf09a3484a8c59eea Mon Sep 17 00:00:00 2001 From: GianlucaMarotta Date: Fri, 22 Jan 2021 10:45:44 +0100 Subject: [PATCH 03/10] CT-207 Implementation of OffCommand --- csp-lmc-common/csp_lmc_common/CspSubarray.py | 86 +++++++++----------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/csp-lmc-common/csp_lmc_common/CspSubarray.py b/csp-lmc-common/csp_lmc_common/CspSubarray.py index 65c6ab4..4c77173 100644 --- a/csp-lmc-common/csp_lmc_common/CspSubarray.py +++ b/csp-lmc-common/csp_lmc_common/CspSubarray.py @@ -352,52 +352,47 @@ class CspSubarray(SKASubarray): self.logger.info("Call Off Command") device = self.target subelement_thr = {} - for fqdn in device._sc_subarray_fqdn: - - # check if the sub-element subarray is already in the - # requested state - if device._sc_subarray_state[fqdn] == tango.DevState.OFF: - continue - - if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: - subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, - name="Thread-OffSequence", - args=(fqdn,)) - subelement_thr[fqdn].start() - - for fqdn in subelement_thr.keys(): - subelement_thr[fqdn].join() - - - if fqdn != device.CbfSubarray: - device._health_state = HealthState.DEGRADED - continue - else: - return (ResultCode.FAILED, message) - - - - - - try: - except tango.DevFailed as tango_err: - message = str(tango_err.args[0].desc) - return (ResultCode.FAILED, message) - - + self.succeeded = [] + try: + # First loop that start the sub-element threads to get the ObsState.EMPTY + for fqdn in device._sc_subarray_fqdn: + # check if the sub-element subarray is already in the + # requested state + if device._sc_subarray_state[fqdn] == tango.DevState.OFF: + continue + if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, + name="Thread-OffSequence", + args=(fqdn,)) + subelement_thr[fqdn].start() + # Second loop check if the thread is succeeded and send the Off command to sub-element + for fqdn in subelement_thr.keys(): + subelement_thr[fqdn].join() + if not self.succeeded[fqdn]: + self.logger.info(f'ObsState of device {fqdn} is not EMPTY. ObsState:{device._sc_subarray_obs_state[fqdn]}') + # TODO: GM: anche se non sono EMPTY li mandiamo in OFF? + if fqdn != device.CbfSubarray: + device._health_state = HealthState.DEGRADED + continue + else: + # TODO: check message + return ResultCode.FAILED, 'CBF is not EMPTY, impossible to send OFF command' + # turn off the sub-element + (result_code, message) = device._sc_subarray_proxies[fqdn].Off() if result_code == ResultCode.FAILED: self.logger.error("Off command failed on device {}".format(fqdn)) if fqdn != device.CbfSubarray: device._health_state = HealthState.DEGRADED continue else: - return (ResultCode.FAILED, message) - - message = "Off command completed OK" - self.logger.info(message) - return (ResultCode.OK, message) - - + return ResultCode.FAILED, message + # TODO: OFF the CSP-Subarray? + except tango.DevFailed as tango_err: + message = str(tango_err.args[0].desc) + return ResultCode.FAILED, message + message = "Off command completed OK" + self.logger.info(message) + return ResultCode.OK, message def off_sequence(self, fqdn): #Off command send the device in the state:OFF, ObsState:EMPTY @@ -411,7 +406,7 @@ class CspSubarray(SKASubarray): self.logger.info('Try to execute Abort command') device._sc_subarray_proxies[fqdn].Abort() while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.ABORTED: - if device._sc_subarray_obs_state[fqdn]==ObsState.FAULT: + if device._sc_subarray_obs_state[fqdn] == ObsState.FAULT: break time.sleep(0.1) except ska.base.commands.CommandError as msg: @@ -427,20 +422,19 @@ class CspSubarray(SKASubarray): time.sleep(0.1) # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition + if device._sc_subarray_obs_state[fqdn] is ObsState.EMPTY: + self.succeeded[fqdn] = True + else: + self.succeeded[fqdn] = False - class AssignResourcesCommand(SKASubarray.AssignResourcesCommand): - @transaction_id def do(self, argin): #TODO: Edit the logger self.logger.info('Assign resource command ... ') return (ResultCode.OK, "Assign Resources command completed OK") - - class ConfigureCommand(SKASubarray.ConfigureCommand): - @transaction_id def do(self, argin): # checks on State, adminMode and obsState values are performed inside the -- GitLab From b9eee9711439d77b3f05b4e830cc6f8479890305 Mon Sep 17 00:00:00 2001 From: Gianluca Marotta Date: Mon, 25 Jan 2021 09:39:10 +0100 Subject: [PATCH 04/10] CT-207 Integration tests for OffCommand; fixed errors --- csp-lmc-common/csp_lmc_common/CspSubarray.py | 16 +++++++++------- .../tests/integration/MidCspSubarray_test.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/csp-lmc-common/csp_lmc_common/CspSubarray.py b/csp-lmc-common/csp_lmc_common/CspSubarray.py index 4c77173..ec74b96 100644 --- a/csp-lmc-common/csp_lmc_common/CspSubarray.py +++ b/csp-lmc-common/csp_lmc_common/CspSubarray.py @@ -38,7 +38,7 @@ from tango import AttrWriteType, DeviceProxy from ska.base import SKASubarray, SKASubarrayStateModel #from ska.base import utils from ska.base.commands import ActionCommand, ResultCode -from ska.base.faults import CapabilityValidationError +from ska.base.faults import CapabilityValidationError, CommandError from ska.base.control_model import HealthState, AdminMode, ObsState, ObsMode from .utils.cspcommons import CmdExecState from .utils.decorators import transaction_id @@ -352,7 +352,7 @@ class CspSubarray(SKASubarray): self.logger.info("Call Off Command") device = self.target subelement_thr = {} - self.succeeded = [] + self.thread_succeeded = [] try: # First loop that start the sub-element threads to get the ObsState.EMPTY for fqdn in device._sc_subarray_fqdn: @@ -368,7 +368,7 @@ class CspSubarray(SKASubarray): # Second loop check if the thread is succeeded and send the Off command to sub-element for fqdn in subelement_thr.keys(): subelement_thr[fqdn].join() - if not self.succeeded[fqdn]: + if not self.thread_succeeded[fqdn]: self.logger.info(f'ObsState of device {fqdn} is not EMPTY. ObsState:{device._sc_subarray_obs_state[fqdn]}') # TODO: GM: anche se non sono EMPTY li mandiamo in OFF? if fqdn != device.CbfSubarray: @@ -390,12 +390,14 @@ class CspSubarray(SKASubarray): except tango.DevFailed as tango_err: message = str(tango_err.args[0].desc) return ResultCode.FAILED, message + super().do() message = "Off command completed OK" self.logger.info(message) return ResultCode.OK, message def off_sequence(self, fqdn): #Off command send the device in the state:OFF, ObsState:EMPTY + self.logger.info('off sequence started!') device = self.target starting_time = time.time() timeout = device._sc_subarray_cmd_duration_expected[fqdn]['off'] @@ -409,7 +411,7 @@ class CspSubarray(SKASubarray): if device._sc_subarray_obs_state[fqdn] == ObsState.FAULT: break time.sleep(0.1) - except ska.base.commands.CommandError as msg: + except CommandError as msg: self.logger.info(msg) # Try to send Restart Command. # Device goes to EMPTY if ObsState is: FAULT, ABORTED @@ -417,15 +419,15 @@ class CspSubarray(SKASubarray): try: self.logger.info('Try to execute Restart command') device._sc_subarray_obs_state[fqdn].Restart() - except ska.base.commands.CommandError as msg: + except CommandError as msg: self.logger.info(msg) time.sleep(0.1) # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition if device._sc_subarray_obs_state[fqdn] is ObsState.EMPTY: - self.succeeded[fqdn] = True + self.thread_succeeded[fqdn] = True else: - self.succeeded[fqdn] = False + self.thread_succeeded[fqdn] = False class AssignResourcesCommand(SKASubarray.AssignResourcesCommand): @transaction_id diff --git a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py index ce9a36f..2dd0251 100755 --- a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py +++ b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py @@ -200,6 +200,24 @@ class TestCspSubarray(TestBase): prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.ON, f"CSP Subarray not OFF") Poller(4, 0.2).check(prober_subarray_state) + @pytest.mark.csp_k8s + def test_OffCommand_after_RESOURCING(self): + self._setup_subarray() + self.midcsp_subarray01.Off() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") + Poller(4, 0.2).check(prober_subarray_obsstate) + + def test_OffCommand_after_CONFIGURE(self): + self._setup_subarray() + self._configure_scan() + self.midcsp_subarray01.Off() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") + Poller(10, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") + Poller(10, 0.2).check(prober_subarray_obsstate) + @pytest.mark.csp_k8s def test_add_receptors_WITH_invalid_id(self): """ -- GitLab From 13feac24b8d7cea772eaac40457f76024e557305 Mon Sep 17 00:00:00 2001 From: Gianluca Marotta Date: Mon, 25 Jan 2021 17:15:10 +0100 Subject: [PATCH 05/10] CT-207 Fix errors in mid integration tests, small change in assign resources --- csp-lmc-common/csp_lmc_common/CspSubarray.py | 18 ++++++++++-------- csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py | 6 +++--- .../tests/integration/MidCspSubarray_test.py | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/csp-lmc-common/csp_lmc_common/CspSubarray.py b/csp-lmc-common/csp_lmc_common/CspSubarray.py index ec74b96..c7ce92b 100644 --- a/csp-lmc-common/csp_lmc_common/CspSubarray.py +++ b/csp-lmc-common/csp_lmc_common/CspSubarray.py @@ -352,7 +352,7 @@ class CspSubarray(SKASubarray): self.logger.info("Call Off Command") device = self.target subelement_thr = {} - self.thread_succeeded = [] + self.thread_succeeded = {} try: # First loop that start the sub-element threads to get the ObsState.EMPTY for fqdn in device._sc_subarray_fqdn: @@ -360,7 +360,7 @@ class CspSubarray(SKASubarray): # requested state if device._sc_subarray_state[fqdn] == tango.DevState.OFF: continue - if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + if device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY: subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, name="Thread-OffSequence", args=(fqdn,)) @@ -398,33 +398,35 @@ class CspSubarray(SKASubarray): def off_sequence(self, fqdn): #Off command send the device in the state:OFF, ObsState:EMPTY self.logger.info('off sequence started!') + self.logger.info(f'FQDN: {fqdn}') device = self.target starting_time = time.time() timeout = device._sc_subarray_cmd_duration_expected[fqdn]['off'] - while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: + while (time.time() - starting_time) < timeout and (device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY): # Try to send Abort Command. # Device goes to ABORTED in case ObsState is: IDLE, READY, CONFIGURING, SCANNING, RESETTING try: self.logger.info('Try to execute Abort command') + self.logger.info(f'ObState: {device._sc_subarray_obs_state[fqdn]}') device._sc_subarray_proxies[fqdn].Abort() - while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.ABORTED: + while (time.time() - starting_time) < timeout and (device._sc_subarray_obs_state[fqdn] != ObsState.ABORTED): if device._sc_subarray_obs_state[fqdn] == ObsState.FAULT: break time.sleep(0.1) - except CommandError as msg: + except Exception as msg: self.logger.info(msg) # Try to send Restart Command. # Device goes to EMPTY if ObsState is: FAULT, ABORTED # ObsState could be aborted from above try section try: self.logger.info('Try to execute Restart command') - device._sc_subarray_obs_state[fqdn].Restart() - except CommandError as msg: + device._sc_subarray_proxies[fqdn].Restart() + except Exception as msg: self.logger.info(msg) time.sleep(0.1) # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition - if device._sc_subarray_obs_state[fqdn] is ObsState.EMPTY: + if device._sc_subarray_obs_state[fqdn] == ObsState.EMPTY: self.thread_succeeded[fqdn] = True else: self.thread_succeeded[fqdn] = False diff --git a/csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py b/csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py index 6d7c060..1bfe5c7 100644 --- a/csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py +++ b/csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py @@ -116,14 +116,14 @@ class MidCspSubarrayBase(CspSubarray): try: resources_dict = json.loads(argin) subarray_id = resources_dict['subarrayID'] - if subarray_id != self.target.SubID: + if subarray_id != int(self.target.SubID): msg = f"Mismatch in subarrayID. Received: {subarray_id} {self.target.SubID}" self.logger.error(msg) - #return (ResultCode.FAILED, msg) + return (ResultCode.FAILED, msg) receptor_list = list(map(int, resources_dict['dish']['receptorIDList'])) except (KeyError, json.JSONDecodeError) as error: msg = f"Something wrong in Json input string: {error}" - raise ValueError(msg) + return (ResultCode.FAILED, msg) return self._add_receptors(receptor_list) def _add_receptors(self, argin): diff --git a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py index 2dd0251..e744509 100755 --- a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py +++ b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py @@ -170,6 +170,12 @@ class TestCspSubarray(TestBase): f"Wrong CSP Subarray obsState {self.midcsp_subarray01.obsState}") Poller(5, 0.2).check(prober_subarray_obstate) + def _build_resources(self, argin): + param = { + 'subarrayID': 1, + 'dish': { 'receptorIDList': list(map(str, argin))}} + return json.dumps(param) + @pytest.mark.csp_k8s def test_AFTER_initialization(self): """ @@ -202,13 +208,26 @@ class TestCspSubarray(TestBase): @pytest.mark.csp_k8s def test_OffCommand_after_RESOURCING(self): + self._setup_subarray + json_config= self._build_resources([1,2]) + self.midcsp_subarray01.AssignResources(json_config) + self.midcsp_subarray01.Off() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") + Poller(4, 0.2).check(prober_subarray_obsstate) + + @pytest.mark.csp_k8s + def test_OffCommand_after_IDLE(self): self._setup_subarray() + self._assign_receptors() self.midcsp_subarray01.Off() prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") Poller(4, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) + @pytest.mark.cps_k8s def test_OffCommand_after_CONFIGURE(self): self._setup_subarray() self._configure_scan() -- GitLab From 3211095ccdcc7dc6ff22dc860f814483cbf2b7a5 Mon Sep 17 00:00:00 2001 From: Gianluca Marotta Date: Mon, 25 Jan 2021 18:13:07 +0100 Subject: [PATCH 06/10] CT-207 changes in OffCommand --- csp-lmc-common/csp_lmc_common/CspSubarray.py | 70 +++++++++----------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/csp-lmc-common/csp_lmc_common/CspSubarray.py b/csp-lmc-common/csp_lmc_common/CspSubarray.py index c7ce92b..889ab06 100644 --- a/csp-lmc-common/csp_lmc_common/CspSubarray.py +++ b/csp-lmc-common/csp_lmc_common/CspSubarray.py @@ -353,44 +353,40 @@ class CspSubarray(SKASubarray): device = self.target subelement_thr = {} self.thread_succeeded = {} - try: - # First loop that start the sub-element threads to get the ObsState.EMPTY - for fqdn in device._sc_subarray_fqdn: - # check if the sub-element subarray is already in the - # requested state - if device._sc_subarray_state[fqdn] == tango.DevState.OFF: - continue - if device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY: - subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, - name="Thread-OffSequence", - args=(fqdn,)) - subelement_thr[fqdn].start() - # Second loop check if the thread is succeeded and send the Off command to sub-element + off_failed = False + # First loop that start the sub-element threads to get the ObsState.EMPTY + for fqdn in device._sc_subarray_fqdn: + # check if the sub-element subarray is already in the + # requested state + if device._sc_subarray_state[fqdn] == tango.DevState.OFF: + continue + if device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY: + subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, + name="Thread-OffSequence", + args=(fqdn,)) + subelement_thr[fqdn].start() + else: + self.logger.info(f'ObsState of device {fqdn} is not EMPTY. ObsState:{device._sc_subarray_obs_state[fqdn]}') + # Second loop check if the thread is succeeded and send the Off command to sub-element + for fqdn in subelement_thr.keys(): + subelement_thr[fqdn].join() + + if any(self.thread_succeeded[fqdn] == True for fqdn in subelement_thr.keys()): for fqdn in subelement_thr.keys(): - subelement_thr[fqdn].join() - if not self.thread_succeeded[fqdn]: - self.logger.info(f'ObsState of device {fqdn} is not EMPTY. ObsState:{device._sc_subarray_obs_state[fqdn]}') - # TODO: GM: anche se non sono EMPTY li mandiamo in OFF? - if fqdn != device.CbfSubarray: - device._health_state = HealthState.DEGRADED - continue - else: - # TODO: check message - return ResultCode.FAILED, 'CBF is not EMPTY, impossible to send OFF command' - # turn off the sub-element - (result_code, message) = device._sc_subarray_proxies[fqdn].Off() - if result_code == ResultCode.FAILED: - self.logger.error("Off command failed on device {}".format(fqdn)) - if fqdn != device.CbfSubarray: - device._health_state = HealthState.DEGRADED - continue - else: - return ResultCode.FAILED, message - # TODO: OFF the CSP-Subarray? - except tango.DevFailed as tango_err: - message = str(tango_err.args[0].desc) - return ResultCode.FAILED, message - super().do() + try: + (result_code, message) = device._sc_subarray_proxies[fqdn].Off() + except tango.DevFailed as tango_err: + message = str(tango_err.args[0].desc) + result_code = ResultCode.FAILED + + if result_code == ResultCode.FAILED: + self.logger.error("Off command failed on device {}".format(fqdn)) + self.logger.info(message) + off_failed = True + + if off_failed: + return ResultCode.FAILED, 'Off command Failed' + message = "Off command completed OK" self.logger.info(message) return ResultCode.OK, message -- GitLab From 662164749e13ef84cdfe15b6c780ef4bb25644de Mon Sep 17 00:00:00 2001 From: egiani Date: Mon, 25 Jan 2021 16:57:43 -0500 Subject: [PATCH 07/10] CT-207: To temporarily solve SKB-26 join the power-on/off thread to synchronize the execution of the On/Standby commands. --- csp-lmc-common/csp_lmc_common/CspMaster.py | 57 +++++++++++++--------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/csp-lmc-common/csp_lmc_common/CspMaster.py b/csp-lmc-common/csp_lmc_common/CspMaster.py index 89d082d..69a3ea9 100644 --- a/csp-lmc-common/csp_lmc_common/CspMaster.py +++ b/csp-lmc-common/csp_lmc_common/CspMaster.py @@ -592,42 +592,48 @@ class CspMaster(SKAMaster): # reset the CSP command execution flag with self._cmd_exec_state_lock: self._cmd_execution_state[cmd_name] = CmdExecState.IDLE - self._update_csp_state() - self.logger.info("CSP State:{}".format(self.get_state())) - self._enable_subarrays(tango_cmd_name) def _enable_subarrays(self, tango_cmd_name): - enable = False - subarray_cmd = tango_cmd_name - if tango_cmd_name == 'On': - enable = True - if tango_cmd_name == 'Standby': - subarray_cmd = 'Off' + """ + Helper method to execute the On[Off] command on the CSP subarrays. + + :param tangp_cmd_name: The command to execute + :type tamgo_cmd_name: string + :return: None + """ + subarray_action = tango_cmd_name.lower() + if subarray_action not in ['on', 'off']: + self.logger.warning(f"Invalid command {subarray_action} to issue on CSP subarray") + return master_state = self.get_state() - if (enable, master_state) not in [(True, tango.DevState.ON), (False, tango.DevState.STANDBY)]: + if (subarray_action, master_state) not in [('on', tango.DevState.ON), ('off', tango.DevState.STANDBY)]: self.logger.warning("CSPMaster is not in the proper state ({})".format(self.get_state())) return try: subarray_group = tango.Group("CSPSubarray") for subarray in self.CspSubarrays: subarray_group.add(subarray) - self.logger.info("Issue command {} on subarray group".format(subarray_cmd)) - answers = subarray_group.command_inout(subarray_cmd) + self.logger.info("Going to switch-{} the subarrays".format(subarray_action)) + answers = subarray_group.command_inout(subarray_action) for reply in answers: if reply.has_failed(): self.logger.info("stack: {}".format(len(reply.get_err_stack()))) for err in reply.get_err_stack(): self.logger.info("err {} reason {}".format(err.desc, err.reason) ) self.logger.warning("Subarray {} failed executing command {}".format(reply.dev_name(), - subarray_cmd)) + subarray_action)) else: (result_code, msg) = reply.get_data() if result_code == ResultCode.FAILED: - self.logger.error(msg[0]) + self.logger.error(f"Subarray {reply.dev_name()}: {msg[0]}") elif result_code == ResultCode.OK: - self.logger.info(msg[0]) + self.logger.info(f"Subarray {reply.dev_name()}: {msg[0]}") + except tango.DevFailed as df: + log_msg = (f"Failure in command {subarray_action} " + "for device {str(fqdn)}: {str(df.args[0].reason)}") + self.logger.error(log_msg) except Exception: - self.logger.error("TANGO Group command failed") + self.logger.error("command {} failed on subarray".format(subarray_action)) def _se_write_adminMode(self, value, device_fqdn): """ @@ -1885,8 +1891,11 @@ class CspMaster(SKAMaster): self._cmd_execution_state['on'] = CmdExecState.RUNNING self._command_thread['on'].start() self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items())) - # sleep for a while to let the thread start - #time.sleep(0.1) + # To temporarily solve SKB-26 -> join the thread to synchronize the command + self._command_thread['on'].join() + self._update_csp_state() + self.logger.info("CSP State:{}".format(self.get_state())) + self._enable_subarrays('On') except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() @@ -1970,8 +1979,9 @@ class CspMaster(SKAMaster): self._cmd_execution_state['off'] = CmdExecState.RUNNING # start the thread self._command_thread['off'].start() - # sleep for a while to let the thread start - #time.sleep(0.1) + self._command_thread['off'].join() + self._update_csp_state() + self.logger.info("CSP State:{}".format(self.get_state())) except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() @@ -2054,8 +2064,11 @@ class CspMaster(SKAMaster): # start the thread self._command_thread['standby'].start() self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items())) - # sleep for a while to let the thread start - #time.sleep(0.1) + # To temprarily solve the SKB-26 -> join the thread to synchronize the command + self._command_thread['standby'].join() + self._update_csp_state() + self.logger.info("CSP State:{}".format(self.get_state())) + self._enable_subarrays('Off') except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() -- GitLab From 9f709bf51768c4e25d5e094d66844fa4f8bb2abc Mon Sep 17 00:00:00 2001 From: toor Date: Tue, 26 Jan 2021 09:56:38 +0100 Subject: [PATCH 08/10] CT-207: Added test for On/Standby sync commands. --- .../tests/integration/MidCspMaster_test.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/csp-lmc-mid/tests/integration/MidCspMaster_test.py b/csp-lmc-mid/tests/integration/MidCspMaster_test.py index 51396a1..455f5a8 100644 --- a/csp-lmc-mid/tests/integration/MidCspMaster_test.py +++ b/csp-lmc-mid/tests/integration/MidCspMaster_test.py @@ -91,7 +91,23 @@ class TestCspMaster(TestBase): assert self.midcsp_master.state() == DevState.ON argin = ["mid_csp_cbf/sub_elt/master",] self.midcsp_master.Standby(argin) - prober_state = Probe(self.midcsp_master, "State", DevState.STANDBY, f"CSP Master not STANDBY") + prober_state = Probe(self.midcsp_master, "State", DevState.STANDBY, + f"CSP Master not STANDBY") + Poller(4, 0.2).check(prober_state) + + def test_issue_Standby_AFTER_On_command(self): + """ + Issue the Standby command just after the On command, without waiting + on the State value. + To solve SKB-26 bug, the power commands are now executed in + synch way. + """ + self._setup_master() + argin = ["mid_csp_cbf/sub_elt/master",] + self.midcsp_master.On(argin) + self.midcsp_master.Standby(argin) + prober_state = Probe(self.midcsp_master, "State", DevState.STANDBY, + f"CSP Master not STANDBY") Poller(4, 0.2).check(prober_state) ''' -- GitLab From 6821f49697200750b11d0144d2f72bd3b9da23d2 Mon Sep 17 00:00:00 2001 From: Gianluca Marotta Date: Tue, 26 Jan 2021 18:11:35 +0100 Subject: [PATCH 09/10] CT-207 Integration tests for Off Command --- .../tests/integration/MidCspSubarray_test.py | 71 ++++++++++++++++--- 1 file changed, 63 insertions(+), 8 deletions(-) diff --git a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py index e744509..e750900 100755 --- a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py +++ b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py @@ -176,7 +176,6 @@ class TestCspSubarray(TestBase): 'dish': { 'receptorIDList': list(map(str, argin))}} return json.dumps(param) - @pytest.mark.csp_k8s def test_AFTER_initialization(self): """ Test for State after CSP startup. @@ -190,7 +189,6 @@ class TestCspSubarray(TestBase): prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) - @pytest.mark.csp_k8s def test_subarray_state_AFTER_on_command_execution(self): """ @@ -206,7 +204,6 @@ class TestCspSubarray(TestBase): prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.ON, f"CSP Subarray not OFF") Poller(4, 0.2).check(prober_subarray_state) - @pytest.mark.csp_k8s def test_OffCommand_after_RESOURCING(self): self._setup_subarray json_config= self._build_resources([1,2]) @@ -216,8 +213,9 @@ class TestCspSubarray(TestBase): Poller(4, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + assert not receptors.any(), f"CSP Subarray is not empty" - @pytest.mark.csp_k8s def test_OffCommand_after_IDLE(self): self._setup_subarray() self._assign_receptors() @@ -226,9 +224,10 @@ class TestCspSubarray(TestBase): Poller(4, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + assert not receptors.any(), f"CSP Subarray is not empty" - @pytest.mark.cps_k8s - def test_OffCommand_after_CONFIGURE(self): + def test_OffCommand_after_CONFIGURING(self): self._setup_subarray() self._configure_scan() self.midcsp_subarray01.Off() @@ -236,8 +235,65 @@ class TestCspSubarray(TestBase): Poller(10, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(10, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + assert not receptors.any(), f"CSP Subarray is not empty" - @pytest.mark.csp_k8s + def test_OffCommand_after_READY(self): + self._setup_subarray() + self._configure_scan() + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.READY, f'CSP Subarray not READY') + Poller(10, 0.2).check(prober_subarray_obsstate) + self.midcsp_subarray01.Off() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") + Poller(10, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") + Poller(10, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + assert not receptors.any(), f"CSP Subarray is not empty" + + def test_OffCommand_after_SCAN(self): + self._setup_subarray() + self._configure_scan() + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.READY, f'CSP Subarray not READY') + Poller(10, 0.2).check(prober_subarray_obsstate) + self.midcsp_subarray01.Scan('2') + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.SCANNING, f'CSP Subarray not SCANNING') + Poller(10, 0.2).check(prober_subarray_obsstate) + self.midcsp_subarray01.Off() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") + Poller(10, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") + Poller(10, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + assert not receptors.any(), f"CSP Subarray is not empty" + def test_OffCommand_after_ABORTED(self): + self._setup_subarray() + self._assign_receptors() + self.midcsp_subarray01.Abort() + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.ABORTED, f'CSP Subarray not ABORTED') + Poller(10, 0.2).check(prober_subarray_obsstate) + self.midcsp_subarray01.Off() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") + Poller(4, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + assert not receptors.any(), f"CSP Subarray is not empty" + @pytest.mark.fault + def test_OffCommand_after_FAULT(self): + self._setup_subarray() + self._assign_receptors() + self.midcsp_subarray01.Configure('{"input":"failed"}') + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.FAULT, f'CSP Subarray not FAULT') + Poller(10, 0.2).check(prober_subarray_obsstate) + self.midcsp_subarray01.Off() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") + Poller(4, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + assert not receptors.any(), f"CSP Subarray is not empty" + def test_add_receptors_WITH_invalid_id(self): """ Test the assignment of a number of invalid receptor IDs to @@ -256,7 +312,6 @@ class TestCspSubarray(TestBase): invalid_receptor_to_assign.append(id_num) if len(invalid_receptor_to_assign) > 3: break - param = { 'subarrayID': 1, 'dish': { 'receptorIDList': list(map(str, invalid_receptor_to_assign))}} -- GitLab From 3746607aa2ed5abeb9d8c2148a0aed040f4fbbcf Mon Sep 17 00:00:00 2001 From: GianlucaMarotta Date: Wed, 27 Jan 2021 09:22:22 +0100 Subject: [PATCH 10/10] CT-207 Updated package, image and chart versions --- csp-lmc-common/HISTORY | 4 +++ csp-lmc-common/csp_lmc_common/release.py | 2 +- csp-lmc-mid/.release | 2 +- csp-lmc-mid/HISTORY | 4 +++ .../charts/mid-csp-umbrella/Chart.yaml | 2 +- csp-lmc-mid/charts/mid-csp/Chart.yaml | 4 +-- csp-lmc-mid/charts/mid-csp/values.yaml | 2 +- csp-lmc-mid/csp_lmc_mid/release.py | 2 +- csp-lmc-mid/requirements.txt | 2 +- .../tests/integration/MidCspSubarray_test.py | 33 +++++++++++++++++-- 10 files changed, 47 insertions(+), 10 deletions(-) diff --git a/csp-lmc-common/HISTORY b/csp-lmc-common/HISTORY index 5d3e275..9b9265b 100644 --- a/csp-lmc-common/HISTORY +++ b/csp-lmc-common/HISTORY @@ -1,3 +1,7 @@ +0.7.1 +- Off command in Subarray drives each sub-element component to the final OFF/EMPTY state. +- CspMaster On/Standby commands are executed synchronously + 0.7.0 - Align CSP.LMC to be compliant with the SKA Base Classes API: add of Assign/ReleaseResources commands. diff --git a/csp-lmc-common/csp_lmc_common/release.py b/csp-lmc-common/csp_lmc_common/release.py index b93729c..45a477e 100755 --- a/csp-lmc-common/csp_lmc_common/release.py +++ b/csp-lmc-common/csp_lmc_common/release.py @@ -10,7 +10,7 @@ """Release information for Python Package""" name = """csp-lmc-common""" -version = "0.7.0" +version = "0.7.1" version_info = version.split(".") description = """SKA CSP.LMC Common Software""" author = "INAF-OAA" diff --git a/csp-lmc-mid/.release b/csp-lmc-mid/.release index 689fa9b..f6a1b63 100644 --- a/csp-lmc-mid/.release +++ b/csp-lmc-mid/.release @@ -9,7 +9,7 @@ """Release information for Python Package""" name = """MID CSP.LMC""" -version = "0.7.0" +version = "0.7.1" version_info = version.split(".") description = """SKA MID CSP.LMC Classes""" author = "E.G" diff --git a/csp-lmc-mid/HISTORY b/csp-lmc-mid/HISTORY index 9eccdf7..f1dc1f5 100644 --- a/csp-lmc-mid/HISTORY +++ b/csp-lmc-mid/HISTORY @@ -1,3 +1,7 @@ +0.7.1 +- use csp-lmc-common 0.7.1 +- updated integration tests + 0.7.0 - use csp-lmc-common 0.7.0 - align Mid CSP.LMC to the SKA Base Classes API diff --git a/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml b/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml index fe6a5dd..188a210 100644 --- a/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml +++ b/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml @@ -15,5 +15,5 @@ dependencies: version: 0.1.1 repository: https://nexus.engageska-portugal.pt/repository/helm-chart - name: mid-csp - version: 0.1.2 + version: 0.1.3 repository: "file://../mid-csp" diff --git a/csp-lmc-mid/charts/mid-csp/Chart.yaml b/csp-lmc-mid/charts/mid-csp/Chart.yaml index 6158b39..47b2f37 100644 --- a/csp-lmc-mid/charts/mid-csp/Chart.yaml +++ b/csp-lmc-mid/charts/mid-csp/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: mid-csp description: A Helm chart for deploying the Mid_CSP.LMC devices on Kubernetes -version: 0.1.2 -appVersion: "0.7.0" +version: 0.1.3 +appVersion: "0.7.1" icon: https://www.skatelescope.org/wp-content/uploads/2016/07/09545_NEW_LOGO_2014.png dependencies: - name: tango-util diff --git a/csp-lmc-mid/charts/mid-csp/values.yaml b/csp-lmc-mid/charts/mid-csp/values.yaml index d56b102..b4c8dfc 100644 --- a/csp-lmc-mid/charts/mid-csp/values.yaml +++ b/csp-lmc-mid/charts/mid-csp/values.yaml @@ -37,7 +37,7 @@ midcsplmc: image: registry: nexus.engageska-portugal.pt/ska-docker image: mid-csp-lmc - tag: 0.7.0 + tag: 0.7.1 pullPolicy: IfNotPresent resources: diff --git a/csp-lmc-mid/csp_lmc_mid/release.py b/csp-lmc-mid/csp_lmc_mid/release.py index 5c450ad..687296c 100755 --- a/csp-lmc-mid/csp_lmc_mid/release.py +++ b/csp-lmc-mid/csp_lmc_mid/release.py @@ -10,7 +10,7 @@ """Release information for Python Package""" name = """mid-csp-lmc""" -version = "0.7.0" +version = "0.7.1" version_info = version.split(".") description = """SKA MID CSP.LMC""" author = "INAF-OAA" diff --git a/csp-lmc-mid/requirements.txt b/csp-lmc-mid/requirements.txt index f807994..047ea76 100644 --- a/csp-lmc-mid/requirements.txt +++ b/csp-lmc-mid/requirements.txt @@ -2,7 +2,7 @@ numpy == 1.17.2 pytango >= 9.3.2 jsonschema >= 3.2.0 lmcbaseclasses >= 0.8.0 -csp-lmc-common >= 0.6.12 +csp-lmc-common >= 0.7.1 ska-log-transactions ska-telescope-model==0.2.0 diff --git a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py index e750900..5e1a228 100755 --- a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py +++ b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py @@ -205,6 +205,10 @@ class TestCspSubarray(TestBase): Poller(4, 0.2).check(prober_subarray_state) def test_OffCommand_after_RESOURCING(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-RESOURCING + """ self._setup_subarray json_config= self._build_resources([1,2]) self.midcsp_subarray01.AssignResources(json_config) @@ -217,6 +221,10 @@ class TestCspSubarray(TestBase): assert not receptors.any(), f"CSP Subarray is not empty" def test_OffCommand_after_IDLE(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-IDLE + """ self._setup_subarray() self._assign_receptors() self.midcsp_subarray01.Off() @@ -228,6 +236,10 @@ class TestCspSubarray(TestBase): assert not receptors.any(), f"CSP Subarray is not empty" def test_OffCommand_after_CONFIGURING(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-CONFIGURING + """ self._setup_subarray() self._configure_scan() self.midcsp_subarray01.Off() @@ -239,6 +251,10 @@ class TestCspSubarray(TestBase): assert not receptors.any(), f"CSP Subarray is not empty" def test_OffCommand_after_READY(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-READY + """ self._setup_subarray() self._configure_scan() prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.READY, f'CSP Subarray not READY') @@ -251,7 +267,11 @@ class TestCspSubarray(TestBase): receptors = self.midcsp_subarray01.assignedReceptors assert not receptors.any(), f"CSP Subarray is not empty" - def test_OffCommand_after_SCAN(self): + def test_OffCommand_after_SCANNING(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-SCANNING + """ self._setup_subarray() self._configure_scan() prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.READY, f'CSP Subarray not READY') @@ -266,7 +286,12 @@ class TestCspSubarray(TestBase): Poller(10, 0.2).check(prober_subarray_obsstate) receptors = self.midcsp_subarray01.assignedReceptors assert not receptors.any(), f"CSP Subarray is not empty" + def test_OffCommand_after_ABORTED(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-ABORTED + """ self._setup_subarray() self._assign_receptors() self.midcsp_subarray01.Abort() @@ -279,8 +304,12 @@ class TestCspSubarray(TestBase): Poller(4, 0.2).check(prober_subarray_obsstate) receptors = self.midcsp_subarray01.assignedReceptors assert not receptors.any(), f"CSP Subarray is not empty" - @pytest.mark.fault + def test_OffCommand_after_FAULT(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-FAULT + """ self._setup_subarray() self._assign_receptors() self.midcsp_subarray01.Configure('{"input":"failed"}') -- GitLab