diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index 4c89ba721..dd80f4a6e 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -73,6 +73,16 @@ def start(self): # Delete the runtime/network directory shutil.rmtree(os.path.join(os.getcwd(), NET_DIR), ignore_errors=True) + # Cleanup any old config files test files + conf_runtime_dir = os.path.join(RUNTIME_DIR,'conf') + shutil.rmtree(conf_runtime_dir, ignore_errors=True) + os.makedirs(conf_runtime_dir, exist_ok=True) + + # Copy the system config file to the runtime directory + system_conf_runtime = os.path.join(conf_runtime_dir,'system.json') + with open(system_conf_runtime, 'w', encoding='utf-8') as f: + json.dump(self.get_session().get_config(), f, indent=2) + # Get all components ready self.load_network_modules() @@ -188,6 +198,11 @@ def _device_discovered(self, mac_addr): stop_filter=self._device_has_ip) wrpcap(os.path.join(device_runtime_dir, 'startup.pcap'), packet_capture) + # Copy the device config file to the runtime directory + runtime_device_conf = os.path.join(device_runtime_dir,'device_config.json') + with open(runtime_device_conf, 'w', encoding='utf-8') as f: + json.dump(self._session.get_target_device().to_config_json(), f, indent=2) + if device.ip_addr is None: LOGGER.info( f'Timed out whilst waiting for {mac_addr} to obtain an IP address') diff --git a/framework/python/src/test_orc/test_orchestrator.py b/framework/python/src/test_orc/test_orchestrator.py index d0ca63b24..560bc5f79 100644 --- a/framework/python/src/test_orc/test_orchestrator.py +++ b/framework/python/src/test_orc/test_orchestrator.py @@ -29,7 +29,8 @@ LOG_NAME = "test_orc" LOGGER = logger.get_logger("test_orc") -RUNTIME_DIR = "runtime/test" +RUNTIME_DIR = "runtime" +RUNTIME_TEST_DIR = os.path.join(RUNTIME_DIR,"test") TEST_MODULES_DIR = "modules/test" MODULE_CONFIG = "conf/module_config.json" LOG_REGEX = r"^[A-Z][a-z]{2} [0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} test_" @@ -65,8 +66,8 @@ def start(self): # Setup the output directory self._host_user = util.get_host_user() - os.makedirs(RUNTIME_DIR, exist_ok=True) - util.run_command(f"chown -R {self._host_user} {RUNTIME_DIR}") + os.makedirs(RUNTIME_TEST_DIR, exist_ok=True) + util.run_command(f"chown -R {self._host_user} {RUNTIME_TEST_DIR}") # Setup the root_certs folder os.makedirs(DEVICE_ROOT_CERTS, exist_ok=True) @@ -137,7 +138,7 @@ def run_test_modules(self): def _write_reports(self, test_report): out_dir = os.path.join( - self._root_path, RUNTIME_DIR, + self._root_path, RUNTIME_TEST_DIR, self._session.get_target_device().mac_addr.replace(":", "")) LOGGER.debug(f"Writing reports to {out_dir}") @@ -233,7 +234,7 @@ def _find_oldest_test(self, completed_tests_dir): def _timestamp_results(self, device): # Define the current device results directory - cur_results_dir = os.path.join(self._root_path, RUNTIME_DIR, + cur_results_dir = os.path.join(self._root_path, RUNTIME_TEST_DIR, device.mac_addr.replace(":", "")) # Define the directory @@ -261,8 +262,7 @@ def _zip_results(self, dest_path): # The runtime directory to include in ZIP path_to_zip = os.path.join( self._root_path, - RUNTIME_DIR, - self._session.get_target_device().mac_addr.replace(":", "")) + RUNTIME_DIR) # Create ZIP file shutil.make_archive(zip_location, "zip", path_to_zip) @@ -319,7 +319,7 @@ def _run_test_module(self, module): try: - device_test_dir = os.path.join(self._root_path, RUNTIME_DIR, + device_test_dir = os.path.join(self._root_path, RUNTIME_TEST_DIR, device.mac_addr.replace(":", "")) root_certs_dir = os.path.join(self._root_path, DEVICE_ROOT_CERTS)