diff --git a/csp-lmc-common/HISTORY b/csp-lmc-common/HISTORY index 6e5d546f080e448f1a95bac7b9389d6dc2906360..bb5236c3256a49d73b0ba741ec8bd21cf952cf74 100644 --- a/csp-lmc-common/HISTORY +++ b/csp-lmc-common/HISTORY @@ -1,3 +1,7 @@ +0.7.4 +- OFF command when sub-element is ON-EMPTY +- Added transaction id to the common section of ADR-18/22 json config file. + 0.7.3 - Solved dead-lock on Abort Command during Configuration - Restart Command check the if subelements are EMPTY diff --git a/csp-lmc-common/csp_lmc_common/CspSubarray.py b/csp-lmc-common/csp_lmc_common/CspSubarray.py index 3ad5bd7e3ba216d3d061b7d15ddaf427d32aa9eb..dabd9e7589d9b6cc6bc11d4b503c006aff313613 100644 --- a/csp-lmc-common/csp_lmc_common/CspSubarray.py +++ b/csp-lmc-common/csp_lmc_common/CspSubarray.py @@ -573,7 +573,8 @@ class CspSubarray(SKASubarray): self.logger.info("Call Off Command") device = self.target subelement_thr = {} - self.thread_succeeded = {} + device_to_turn_off = [] + self.empty_succeeded = {} off_failed = False # First loop that start the sub-element threads to get the ObsState.EMPTY for fqdn in device._sc_subarray_fqdn: @@ -581,20 +582,25 @@ class CspSubarray(SKASubarray): # requested state if device._sc_subarray_state[fqdn] == tango.DevState.OFF: continue - if device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY: + elif 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() + device_to_turn_off.append(fqdn) else: - self.logger.info(f'ObsState of device {fqdn} is not EMPTY. ObsState:{device._sc_subarray_obs_state[fqdn]}') + self.logger.info(f'ObsState of device {fqdn} is already EMPTY. ObsState:{device._sc_subarray_obs_state[fqdn]}') + device_to_turn_off.append(fqdn) + self.empty_succeeded[fqdn] = True + # 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(): + if all(self.empty_succeeded[fqdn] for fqdn in device_to_turn_off): + for fqdn in device_to_turn_off: try: + self.logger.info('Sending Off Command...') (result_code, message) = device._sc_subarray_proxies[fqdn].Off() except tango.DevFailed as tango_err: message = str(tango_err.args[0].desc) @@ -644,9 +650,9 @@ class CspSubarray(SKASubarray): # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition if device._sc_subarray_obs_state[fqdn] == ObsState.EMPTY: - self.thread_succeeded[fqdn] = True + self.empty_succeeded[fqdn] = True else: - self.thread_succeeded[fqdn] = False + self.empty_succeeded[fqdn] = False class AssignResourcesCommand(SKASubarray.AssignResourcesCommand): @transaction_id diff --git a/csp-lmc-common/csp_lmc_common/csp_manage_json.py b/csp-lmc-common/csp_lmc_common/csp_manage_json.py index 9d88f013b434eea43600d5a49a7a9f9c8c228097..e28103b56529f4715a195b5eea4d23ae02053664 100644 --- a/csp-lmc-common/csp_lmc_common/csp_manage_json.py +++ b/csp-lmc-common/csp_lmc_common/csp_manage_json.py @@ -66,6 +66,8 @@ class JsonConfiguration: """ common_dict = self.get_section('common') cbf_dict = self.get_section('cbf') + if 'transaction_id' in self.config: + common_dict['transaction_id'] = self.get_section('transaction_id') config_converted = {**common_dict, **cbf_dict} validate_csp_config(version=0, config=config_converted) self.config = config_converted diff --git a/csp-lmc-common/csp_lmc_common/release.py b/csp-lmc-common/csp_lmc_common/release.py index 4440c19203290c08626c7cc12d2aa4150242d645..f889629f207536d7dedda68a0f53b7a031548818 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.3" +version = "0.7.4" version_info = version.split(".") description = """SKA CSP.LMC Common Software""" author = "INAF-OAA" diff --git a/csp-lmc-common/tests/unit/cspsubarray_unit_test.py b/csp-lmc-common/tests/unit/cspsubarray_unit_test.py index a2c9893d1a7b4ea829f21aae4369045aa9dcb71a..bee02f9d5b28a869ada3571bc75166573f32d9f4 100644 --- a/csp-lmc-common/tests/unit/cspsubarray_unit_test.py +++ b/csp-lmc-common/tests/unit/cspsubarray_unit_test.py @@ -81,6 +81,8 @@ def test_cspsbarray_state_after_On_WITH_exception_raised_by_subelement_subarray( with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: cbf_subarray_device_proxy_mock.On.side_effect = raise_devfailed_exception pss_subarray_device_proxy_mock.On.side_effect = return_ok + prober_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") + Poller(3, 0.1).check(prober_state) tango_context.device.On() assert tango_context.device.State() == DevState.FAULT assert tango_context.device.obsState == ObsState.EMPTY @@ -108,6 +110,8 @@ def test_cspsbarray_state_after_On_WITH_command_failed_code_returned_by_subeleme with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: cbf_subarray_device_proxy_mock.On.side_effect = return_failed pss_subarray_device_proxy_mock.On.side_effect = return_ok + prober_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") + Poller(3, 0.1).check(prober_state) tango_context.device.On() assert tango_context.device.State() == DevState.FAULT assert tango_context.device.obsState == ObsState.EMPTY @@ -134,6 +138,8 @@ def test_cspsbarray_state_after_On_WITH_command_failed_code_returned_by_pss_suba with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: cbf_subarray_device_proxy_mock.On.side_effect = return_ok pss_subarray_device_proxy_mock.On.side_effect = return_failed + prober_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") + Poller(3, 0.1).check(prober_state) tango_context.device.On() assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.EMPTY @@ -161,6 +167,8 @@ def test_cspsbarray_state_after_On_forwarded_to_subelement_subarray(): with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: cbf_subarray_device_proxy_mock.On.side_effect = return_ok pss_subarray_device_proxy_mock.On.side_effect = return_ok + prober_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") + Poller(3, 0.1).check(prober_state) tango_context.device.On() assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.EMPTY @@ -192,8 +200,8 @@ def test_cspsubarray_transaction_id_in_log(capsys): with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: cbf_subarray_device_proxy_mock.On.side_effect = return_ok pss_subarray_device_proxy_mock.On.side_effect = return_ok - prober_obs_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") - Poller(3, 0.1).check(prober_obs_state) + prober_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") + Poller(3, 0.1).check(prober_state) tango_context.device.On() assert tango_context.device.State() == DevState.ON #tango_context.device.AssignResources('{"subarrayID":1,"dish":{"receptorIDList":["0001","0002"]}}') diff --git a/csp-lmc-mid/.release b/csp-lmc-mid/.release index 8a6766614b2f4cd55f36694b0375e02d13ee690b..4b40209ae9b0330311963dfcbdd64362748a6d92 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.3" +version = "0.7.4" version_info = version.split(".") description = """SKA MID CSP.LMC Classes""" author = "E.G" @@ -20,5 +20,5 @@ copyright = """""" #!!!! UPDATE THE MID-CSP IMAGE VERSION #!!!! DO BEFORE TAGGING !!!! -release=0.7.3 -tag=mid-csp-lmc-0.7.3 +release=0.7.4 +tag=mid-csp-lmc-0.7.4 diff --git a/csp-lmc-mid/HISTORY b/csp-lmc-mid/HISTORY index 295c86eaac3002a7dd5f0bfe6b3cfb92417e80a0..e8b4a5c7cedeb8e8f650314f6cff917954e93be6 100644 --- a/csp-lmc-mid/HISTORY +++ b/csp-lmc-mid/HISTORY @@ -1,3 +1,8 @@ +0.7.4 +- use csp-lmc-common 0.7.4 +- update integration test for transaction id and off command when empty +!!! Release helm chart 0.1.5 !!! + 0.7.3 -use csp-lmc-common 0.7.3 !!! Release helm chart 0.1.4 !!! diff --git a/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml b/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml index b36937528dc0975d01af924340ed36e8a8f305a5..9ac3b8747ab604d8d59d8684b4978686d712dd0c 100644 --- a/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml +++ b/csp-lmc-mid/charts/mid-csp-umbrella/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: mid-csp-umbrella description: A Helm chart for deploying the whole Mid_CSP prototype on Kubernetes version: 0.1.0 -appVersion: 0.7.3 +appVersion: 0.7.4 icon: https://www.skatelescope.org/wp-content/uploads/2016/07/09545_NEW_LOGO_2014.png dependencies: - name: tango-base @@ -15,5 +15,5 @@ dependencies: version: 0.1.1 repository: https://nexus.engageska-portugal.pt/repository/helm-chart - name: mid-csp - version: 0.1.4 + version: 0.1.5 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 62959738089f586bbbcde09c4cf8bfc10adcc96b..c8af0616d304b87626ae0449f27fb5d5bc57f281 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.4 -appVersion: "0.7.3" +version: 0.1.5 +appVersion: "0.7.4" 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 b6b761bb0c348d03e485f84e5f64dab90055ca1c..2c27adda32efeb9e1fdbd7125364a02b0db64064 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.3 + tag: 0.7.4 pullPolicy: IfNotPresent resources: diff --git a/csp-lmc-mid/csp_lmc_mid/release.py b/csp-lmc-mid/csp_lmc_mid/release.py index 515bf05926178e927aef65cb85b8364b59eea47a..c64bc1ae633e49f92091c6bf915d39d2f33028d4 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.3" +version = "0.7.4" 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 95dacc13b0325d384d44dabd7b71f2f05dca0b42..5b822709d48460555915f2b69917af5be3993f29 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.7.3 +csp-lmc-common >= 0.7.4 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 ff3fc2f536063f056e2036d69316462a4a7d1d97..835f18278fc07b2305eed6bc98c7cbeb3068d766 100755 --- a/csp-lmc-mid/tests/integration/MidCspSubarray_test.py +++ b/csp-lmc-mid/tests/integration/MidCspSubarray_test.py @@ -76,24 +76,15 @@ class TestCspSubarray(TestBase): subarray_state = self.midcsp_subarray01.State() obs_state = self.midcsp_subarray01.obsState if subarray_state == DevState.ON: - if obs_state == ObsState.FAULT: - self.midcsp_subarray01.ObsReset() - prober_obs_state = Probe(self.midcsp_subarray01, "obsState", ObsState.IDLE, f"CSP Subarray not IDLE") - Poller(4, 0.2).check(prober_obs_state) - obs_state = self.midcsp_subarray01.obsState - if obs_state == ObsState.EMPTY: - return - if obs_state == ObsState.READY: - self._goto_idle() - if obs_state == ObsState.ABORTED: - self.midcsp_subarray01.ObsReset() - prober_obs_state = Probe(self.midcsp_subarray01, "obsState", ObsState.IDLE, f"CSP Subarray not IDLE") - Poller(4, 0.2).check(prober_obs_state) - obs_state = self.midcsp_subarray01.obsState - if obs_state == ObsState.IDLE: - self._release_all_receptors() - prober_obs_state = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") - Poller(4, 0.2).check(prober_obs_state) + 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) + self.midcsp_subarray01.On() + prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.ON, f"CSP Subarray not ON") + Poller(4, 0.2).check(prober_subarray_state) + def _setup_subarray_off(self): """ Set the subarray state to OFF-EMPTY @@ -178,7 +169,17 @@ class TestCspSubarray(TestBase): 'subarrayID': 1, 'dish': { 'receptorIDList': list(map(str, argin))}} return json.dumps(param) - + + @pytest.mark.transaction_id_in_CBF + def test_transaction_id_is_present_in_CBF_configuration(self): + """ + Test if the transaction id is properly sent to CBF + """ + self._configure_scan() + latest_configuration = self.cbf_subarray01.latestscanconfig + assert 'transaction_id' in latest_configuration + + @pytest.mark.init_EMPTY def test_AFTER_initialization(self): """ @@ -315,6 +316,30 @@ 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.off_empty + def test_OffCommand_after_EMPTY(self): + """ + Test that the Off command send the device in OFF-EMPTY + if it is ON-EMPTY + """ + self._setup_subarray() + subarray_state = self.midcsp_subarray01.State() + obs_state = self.midcsp_subarray01.obsState + LOGGER.info("CSPSubarray state before test:{}-{}".format(subarray_state, obs_state)) + 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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF Subarray not EMPTY") + Poller(4, 0.2).check(prober_subarray_obsstate) + receptors = self.midcsp_subarray01.assignedReceptors + LOGGER.info(f'type of {type(receptors)}') + LOGGER.info(f'list of receptors{receptors}') + assert not receptors.any(), f"CSP Subarray is not empty" + @pytest.mark.off_resourcing def test_OffCommand_after_RESOURCING(self): """ @@ -335,6 +360,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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF Subarray not EMPTY") + Poller(4, 0.2).check(prober_subarray_obsstate) receptors = self.midcsp_subarray01.assignedReceptors LOGGER.info(f'list of receptors{receptors}') assert not receptors.any(), f"CSP Subarray is not empty" @@ -351,6 +380,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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF 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" @@ -366,6 +399,10 @@ 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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF 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" @@ -383,6 +420,10 @@ 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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF 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" @@ -404,6 +445,10 @@ 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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF 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" @@ -422,6 +467,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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF 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" @@ -440,6 +489,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) + prober_subarray_state = Probe(self.cbf_subarray01, "State", DevState.OFF, f"CBF Subarray not OFF") + Poller(4, 0.2).check(prober_subarray_state) + prober_subarray_obsstate = Probe(self.cbf_subarray01, "obsState", ObsState.EMPTY, f"CBF 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"