From 72009653a908da04d258882878340dbd9ca19a48 Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Wed, 16 Apr 2025 12:28:29 -0600 Subject: [PATCH 1/2] Add option to allow devices to disconnect during monitor period --- framework/python/src/core/session.py | 10 ++++++++++ .../src/net_orc/network_orchestrator.py | 20 +++++++++---------- local/system.json.example | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/framework/python/src/core/session.py b/framework/python/src/core/session.py index 5ec50423d..16c8f056b 100644 --- a/framework/python/src/core/session.py +++ b/framework/python/src/core/session.py @@ -39,6 +39,7 @@ MAX_DEVICE_REPORTS_KEY = 'max_device_reports' ORG_NAME_KEY = 'org_name' TEST_CONFIG_KEY = 'test_modules' +ALLOW_DISCONNECT_KEY='allow_disconnect' CERTS_PATH = 'local/root_certs' CONFIG_FILE_PATH = 'local/system.json' STATUS_TOPIC = 'status' @@ -203,6 +204,7 @@ def _get_default_config(self): 'log_level': 'INFO', 'startup_timeout': 60, 'monitor_period': 30, + 'allow_disconnect': False, 'max_device_reports': 0, 'api_url': 'http://localhost', 'api_port': 8000, @@ -241,6 +243,10 @@ def _load_config(self): self._config[MONITOR_PERIOD_KEY] = config_file_json.get( MONITOR_PERIOD_KEY) + if ALLOW_DISCONNECT_KEY in config_file_json: + self._config[ALLOW_DISCONNECT_KEY] = config_file_json.get( + ALLOW_DISCONNECT_KEY) + if LOG_LEVEL_KEY in config_file_json: self._config[LOG_LEVEL_KEY] = config_file_json.get(LOG_LEVEL_KEY) @@ -509,6 +515,10 @@ def get_all_reports(self): def add_total_tests(self, no_tests): self._total_tests += no_tests + + def get_allow_disconnect(self): + return self._config.get(ALLOW_DISCONNECT_KEY) + def get_total_tests(self): return self._total_tests diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index 956c9e1b2..bb9046e11 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -318,16 +318,16 @@ def _start_device_monitor(self, device): TestrunStatus.CANCELLED): sniffer.stop() return - - if not self._ip_ctrl.check_interface_status( - self._session.get_device_interface()): - try: - sniffer.stop() - except Scapy_Exception: - LOGGER.error('Device adapter disconnected whilst monitoring.') - finally: - self._session.set_status(TestrunStatus.CANCELLED) - LOGGER.error('Device interface disconnected, cancelling Testrun') + if not self._session.get_allow_disconnect(): + if not self._ip_ctrl.check_interface_status( + self._session.get_device_interface()): + try: + sniffer.stop() + except Scapy_Exception: + LOGGER.error('Device adapter disconnected whilst monitoring.') + finally: + self._session.set_status(TestrunStatus.CANCELLED) + LOGGER.error('Device interface disconnected, cancelling Testrun') LOGGER.debug('Writing packets to monitor.pcap') wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'), diff --git a/local/system.json.example b/local/system.json.example index df89b502f..7aea31b90 100644 --- a/local/system.json.example +++ b/local/system.json.example @@ -6,6 +6,7 @@ "log_level": "INFO", "startup_timeout": 60, "monitor_period": 300, + "allow_disconnect": True, "max_device_reports": 0, "org_name": "" } From 38f4b89735edd8a6033e4415d2534abe153b9416 Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Wed, 16 Apr 2025 12:31:20 -0600 Subject: [PATCH 2/2] update example config --- local/system.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/system.json.example b/local/system.json.example index 7aea31b90..43527240f 100644 --- a/local/system.json.example +++ b/local/system.json.example @@ -6,7 +6,7 @@ "log_level": "INFO", "startup_timeout": 60, "monitor_period": 300, - "allow_disconnect": True, + "allow_disconnect": false, "max_device_reports": 0, "org_name": "" }