Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions framework/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import sys
import json
import signal
import time
import logger
from device import Device

Expand Down Expand Up @@ -57,21 +58,22 @@ def start(self):

self._load_devices()

self._start_network()

if self._net_only:
LOGGER.info("Network only option configured, no tests will be run")
self._start_network()
time.sleep(RUNTIME)
else:
self._start_network()
self._start_tests()
self._net_orc.listener.register_callback(
self._device_discovered,
[NetworkEvent.DEVICE_DISCOVERED])

LOGGER.info("Waiting for devices on the network...")

# Check timeout and whether testing is currently in progress before stopping
time.sleep(RUNTIME)
self.stop()

# Register callbacks
# Disable for now as this is causing boot failures when no devices are discovered
# self._net_orc.listener.register_callback(
# self._device_discovered,
# [NetworkEvent.DEVICE_DISCOVERED])

def stop(self,kill=False):
self._stop_tests()
self._stop_network(kill=kill)
Expand Down Expand Up @@ -125,9 +127,8 @@ def _get_config_abs(self,config_file=None):
def _start_network(self):
self._net_orc.start()

def _start_tests(self):
def _run_tests(self):
"""Iterate through and start all test modules."""

self._test_orc.start()

def _stop_network(self,kill=False):
Expand Down Expand Up @@ -167,6 +168,9 @@ def _device_discovered(self, mac_addr):
LOGGER.info(
f'Discovered {device.make} {device.model} on the network')
else:
device = Device(make=None, model=None, mac_addr=mac_addr)
LOGGER.info(
f'A new device has been discovered with mac address {device.mac_addr}')
return device
f'A new device has been discovered with mac address {mac_addr}')

# TODO: Pass device information to test orchestrator/runner
self._run_tests()
4 changes: 3 additions & 1 deletion test_orc/modules/baseline/bin/start_test_module
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ chown $HOST_USER:$HOST_USER $RESULT_FILE
# Run the python scrip that will execute the tests for this module
# -u flag allows python print statements
# to be logged by docker by running unbuffered
python3 -u $PYTHON_SRC_DIR/run.py "-m $MODULE_NAME"
python3 -u $PYTHON_SRC_DIR/run.py "-m $MODULE_NAME"

echo Module has finished
2 changes: 0 additions & 2 deletions test_orc/modules/baseline/python/src/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def run_tests(self):
self.module_test2 = False
LOGGER.info("Test 2 complete.")

time.sleep(10)

def generate_results(self):
results = []
results.append(self.generate_result("Test 1", self.module_test1))
Expand Down
2 changes: 1 addition & 1 deletion test_orc/python/src/module.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Represemts a test module."""
from dataclasses import dataclass
from docker.client.Container import Container
from docker.models.containers import Container

@dataclass
class TestModule: # pylint: disable=too-few-public-methods,too-many-instance-attributes
Expand Down
25 changes: 3 additions & 22 deletions test_orc/python/src/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import docker
from docker.types import Mount
import logger
from module import TestModule

LOG_NAME = "test_orc"
LOGGER = logger.get_logger('test_orc')
LOGGER = logger.get_logger("test_orc")
RUNTIME_DIR = "runtime"
TEST_MODULES_DIR = "modules"
MODULE_CONFIG = "conf/module_config.json"
Expand Down Expand Up @@ -196,24 +197,4 @@ def _stop_module(self, module, kill=False):
container.stop()
LOGGER.debug("Container stopped:" + module.container_name)
except docker.errors.NotFound:
pass

class TestModule: # pylint: disable=too-few-public-methods,too-many-instance-attributes
"""Represents a test module."""

def __init__(self):
self.name = None
self.display_name = None
self.description = None

self.build_file = None
self.container = None
self.container_name = None
self.image_name = None
self.enable_container = True

self.timeout = 60

# Absolute path
self.dir = None
self.dir_name = None
pass