From 7ac668dd607c065c084157bbb65457c0fc0a935b Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Tue, 30 Apr 2024 16:49:58 +0100 Subject: [PATCH] List modules --- framework/python/src/api/api.py | 20 ++++++++++++++++++++ framework/python/src/core/testrun.py | 13 +++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/framework/python/src/api/api.py b/framework/python/src/api/api.py index fe76a40d0..2bd227174 100644 --- a/framework/python/src/api/api.py +++ b/framework/python/src/api/api.py @@ -95,6 +95,9 @@ def __init__(self, test_run): self._router.add_api_route("/device/edit", self.edit_device, methods=["POST"]) + + self._router.add_api_route("/system/modules", + self.get_test_modules) # Allow all origins to access the API origins = ["*"] @@ -545,6 +548,20 @@ async def get_results(self, response: Response, response.status_code = 404 return self._generate_msg(False, "Test results could not be found") + async def get_test_modules(self): + + LOGGER.debug("Received request to list test modules") + + test_modules = [] + + for test_module in self._get_test_run().get_test_orc().get_test_modules(): + + # Only add module if it is an actual, enabled test module + if (test_module.enabled and test_module.enable_container): + test_modules.append(test_module.display_name) + + return test_modules + def _validate_device_json(self, json_obj): # Check all required properties are present @@ -569,3 +586,6 @@ def _validate_device_json(self, json_obj): return False return True + + def _get_test_run(self): + return self._test_run diff --git a/framework/python/src/core/testrun.py b/framework/python/src/core/testrun.py index ac4434ef1..d7b4f991a 100644 --- a/framework/python/src/core/testrun.py +++ b/framework/python/src/core/testrun.py @@ -97,14 +97,18 @@ def __init__(self, if validate: self._session.add_runtime_param('validate') - self.load_all_devices() - self._net_orc = net_orc.NetworkOrchestrator( session=self._session) self._test_orc = test_orc.TestOrchestrator( self._session, self._net_orc) + # Load device repository + self.load_all_devices() + + # Load test modules + self._test_orc.start() + if self._no_ui: # Check Testrun is able to start @@ -311,8 +315,6 @@ def start(self): if self._net_only: LOGGER.info('Network only option configured, no tests will be run') else: - self._test_orc.start() - self.get_net_orc().get_listener().register_callback( self._device_stable, [NetworkEvent.DEVICE_STABLE] @@ -369,6 +371,9 @@ def get_config_file(self): def get_net_orc(self): return self._net_orc + def get_test_orc(self): + return self._test_orc + def _start_network(self): # Start the network orchestrator if not self.get_net_orc().start():