From fdf20d3d81cb2d21791ade8b3c40dd3c64eb1e50 Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Wed, 3 Jul 2024 13:26:28 -0600 Subject: [PATCH] Update zip file to use /tmp directory Update device report folder Update file paths to use old and new patterns --- framework/python/src/api/api.py | 13 +++++++++++-- framework/python/src/core/testrun.py | 10 ++++++++++ framework/python/src/test_orc/test_orchestrator.py | 7 ++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/framework/python/src/api/api.py b/framework/python/src/api/api.py index 6a66613b2..efe5b52d0 100644 --- a/framework/python/src/api/api.py +++ b/framework/python/src/api/api.py @@ -540,9 +540,18 @@ async def edit_device(self, request: Request, response: Response): return self._generate_msg(False, "Invalid JSON received") async def get_report(self, response: Response, device_name, timestamp): - - file_path = os.path.join(DEVICES_PATH, device_name, "reports", timestamp, + device = self._session.get_device_by_name(device_name) + + # 1.3 file path + file_path = os.path.join(DEVICES_PATH, device_name, "reports", timestamp,'test', + device.mac_addr.replace(':',''), + "report.pdf") + if not os.path.isfile(file_path): + # pre 1.3 file path + file_path = os.path.join(DEVICES_PATH, device_name, "reports", timestamp, "report.pdf") + + LOGGER.debug(f"Received get report request for {device_name} / {timestamp}") if os.path.isfile(file_path): return FileResponse(file_path) diff --git a/framework/python/src/core/testrun.py b/framework/python/src/core/testrun.py index 5ca763c93..5b43cfd65 100644 --- a/framework/python/src/core/testrun.py +++ b/framework/python/src/core/testrun.py @@ -209,10 +209,20 @@ def _load_test_reports(self, device): LOGGER.info(f'Loading reports from {reports_folder}') for report_folder in os.listdir(reports_folder): + # 1.3 file path report_json_file_path = os.path.join( reports_folder, report_folder, + 'test', + device.mac_addr.replace(':',''), 'report.json') + + if not os.path.isfile(report_json_file_path): + # Revert to pre 1.3 file path + report_json_file_path = os.path.join( + reports_folder, + report_folder, + 'report.json') # Check if the report.json file exists if not os.path.isfile(report_json_file_path): diff --git a/framework/python/src/test_orc/test_orchestrator.py b/framework/python/src/test_orc/test_orchestrator.py index d3c12d905..ac871e6f0 100644 --- a/framework/python/src/test_orc/test_orchestrator.py +++ b/framework/python/src/test_orc/test_orchestrator.py @@ -242,8 +242,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_TEST_DIR, - device.mac_addr.replace(":", "")) + cur_results_dir = os.path.join(self._root_path, RUNTIME_DIR) # Define the directory completed_results_dir = os.path.join( @@ -273,9 +272,7 @@ def zip_results(self, timestamp) # Define where to save the zip file - zip_location = os.path.join(LOCAL_DEVICE_REPORTS.replace( - "{device_folder}", device.device_folder), timestamp - ) + zip_location = os.path.join('/tmp/testrun',timestamp) # Include profile if specified if profile is not None: