From 70ce5a022453db43998b02e1f61be9d72605578a Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Tue, 23 Jul 2024 15:05:07 -0600 Subject: [PATCH 1/2] Fix individual test disabling when run from the UI --- framework/python/src/api/api.py | 11 ++++++++++- framework/python/src/net_orc/network_orchestrator.py | 1 - modules/test/base/python/src/test_module.py | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/python/src/api/api.py b/framework/python/src/api/api.py index ccab0652b..611ec167d 100644 --- a/framework/python/src/api/api.py +++ b/framework/python/src/api/api.py @@ -234,7 +234,16 @@ async def start_test_run(self, request: Request, response: Response): False, "Configured interfaces are not " + "ready for use. Ensure required interfaces " + "are connected.") - device.test_modules = body_json["device"]["test_modules"] + # UI doesn't send individual test configs so we need to + # merge these manually until the UI is updated to handle + # the full config file + for module_name, module_config in device.test_modules.items(): + # Check if the module exists in UI test modules + if module_name in body_json["device"]["test_modules"]: + # Merge the enabled state + module_config["enabled"] = body_json["device"]["test_modules"][module_name]["enabled"] + + LOGGER.info(f'Device config{device.test_modules}') LOGGER.info("Starting Testrun with device target " + f"{device.manufacturer} {device.model} with " + diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index 0f98df8d0..ed90fabbf 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -791,7 +791,6 @@ def network_adapters_checker(self, mgtt_client, topic): """Checks for changes in network adapters and sends a message to the frontend """ - LOGGER.debug('checking network adatpers...') try: adapters = self._session.detect_network_adapters_change() if adapters: diff --git a/modules/test/base/python/src/test_module.py b/modules/test/base/python/src/test_module.py index 00f74df82..18a3981e4 100644 --- a/modules/test/base/python/src/test_module.py +++ b/modules/test/base/python/src/test_module.py @@ -117,6 +117,7 @@ def run_tests(self): LOGGER.info(f'Test {test["name"]} not implemented. Skipping') else: LOGGER.debug(f'Test {test["name"]} is disabled') + result = 'Disabled', 'Test disabled, did not run' if result is not None: # Compliant or non-compliant as a boolean only From d349d0e5b751ee94e5942b8d145e6ca68c1ba4e0 Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Wed, 24 Jul 2024 13:16:45 +0100 Subject: [PATCH 2/2] Remove disabled result for now --- modules/test/base/python/src/test_module.py | 6 +++++- modules/test/ntp/python/src/ntp_module.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/test/base/python/src/test_module.py b/modules/test/base/python/src/test_module.py index 18a3981e4..a59a05239 100644 --- a/modules/test/base/python/src/test_module.py +++ b/modules/test/base/python/src/test_module.py @@ -115,9 +115,13 @@ def run_tests(self): LOGGER.error(e) else: LOGGER.info(f'Test {test["name"]} not implemented. Skipping') + test['result'] = 'Error' + test['description'] = 'This test could not be found' else: LOGGER.debug(f'Test {test["name"]} is disabled') - result = 'Disabled', 'Test disabled, did not run' + + # To be added in v1.3.2 + # result = 'Disabled', 'This test is disabled and did not run' if result is not None: # Compliant or non-compliant as a boolean only diff --git a/modules/test/ntp/python/src/ntp_module.py b/modules/test/ntp/python/src/ntp_module.py index 453c992e6..d9d277534 100644 --- a/modules/test/ntp/python/src/ntp_module.py +++ b/modules/test/ntp/python/src/ntp_module.py @@ -233,12 +233,12 @@ def _ntp_network_ntp_support(self): result = False, 'Device has not sent any NTP requests' elif device_sends_ntp3 and device_sends_ntp4: result = False, ('Device sent NTPv3 and NTPv4 packets. ' + - 'NTPv3 is not allowed.') + 'NTPv3 is not allowed') elif device_sends_ntp3: result = False, ('Device sent NTPv3 packets. ' - 'NTPv3 is not allowed.') + 'NTPv3 is not allowed') elif device_sends_ntp4: - result = True, 'Device sent NTPv4 packets.' + result = True, 'Device sent NTPv4 packets' LOGGER.info(result[1]) return result