Skip to content

Commit cd37a38

Browse files
jboddeysofyakurilova
authored andcommitted
List modules (#425)
1 parent 8be1567 commit cd37a38

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

framework/python/src/api/api.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def __init__(self, test_run):
9595
self._router.add_api_route("/device/edit",
9696
self.edit_device,
9797
methods=["POST"])
98+
99+
self._router.add_api_route("/system/modules",
100+
self.get_test_modules)
98101

99102
# Allow all origins to access the API
100103
origins = ["*"]
@@ -551,6 +554,20 @@ async def get_results(self, response: Response,
551554
response.status_code = 404
552555
return self._generate_msg(False, "Test results could not be found")
553556

557+
async def get_test_modules(self):
558+
559+
LOGGER.debug("Received request to list test modules")
560+
561+
test_modules = []
562+
563+
for test_module in self._get_test_run().get_test_orc().get_test_modules():
564+
565+
# Only add module if it is an actual, enabled test module
566+
if (test_module.enabled and test_module.enable_container):
567+
test_modules.append(test_module.display_name)
568+
569+
return test_modules
570+
554571
def _validate_device_json(self, json_obj):
555572

556573
# Check all required properties are present
@@ -575,3 +592,6 @@ def _validate_device_json(self, json_obj):
575592
return False
576593

577594
return True
595+
596+
def _get_test_run(self):
597+
return self._test_run

framework/python/src/core/testrun.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,18 @@ def __init__(self,
100100
if validate:
101101
self._session.add_runtime_param('validate')
102102

103-
self.load_all_devices()
104-
105103
self._net_orc = net_orc.NetworkOrchestrator(
106104
session=self._session)
107105
self._test_orc = test_orc.TestOrchestrator(
108106
self._session,
109107
self._net_orc)
110108

109+
# Load device repository
110+
self.load_all_devices()
111+
112+
# Load test modules
113+
self._test_orc.start()
114+
111115
if self._no_ui:
112116

113117
# Check Testrun is able to start
@@ -317,8 +321,6 @@ def start(self):
317321
if self._net_only:
318322
LOGGER.info('Network only option configured, no tests will be run')
319323
else:
320-
self._test_orc.start()
321-
322324
self.get_net_orc().get_listener().register_callback(
323325
self._device_stable,
324326
[NetworkEvent.DEVICE_STABLE]
@@ -375,6 +377,9 @@ def get_config_file(self):
375377
def get_net_orc(self):
376378
return self._net_orc
377379

380+
def get_test_orc(self):
381+
return self._test_orc
382+
378383
def _start_network(self):
379384
# Start the network orchestrator
380385
if not self.get_net_orc().start():

0 commit comments

Comments
 (0)