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
3 changes: 3 additions & 0 deletions framework/python/src/common/testreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def __init__(self,
self._report_url = ''
self._cur_page = 0

def update_device_profile(self, additional_info):
self._device['device_profile'] = additional_info

def add_module_reports(self, module_reports):
self._module_reports = module_reports

Expand Down
45 changes: 44 additions & 1 deletion framework/python/src/test_orc/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def _timestamp_results(self, device):

return completed_results_dir

def zip_results(self, device, timestamp, profile):
def zip_results(self, device, timestamp: str, profile):

try:
LOGGER.debug("Archiving test results")
Expand All @@ -357,6 +357,49 @@ def zip_results(self, device, timestamp, profile):
LOCAL_DEVICE_REPORTS.replace("{device_folder}", device.device_folder),
timestamp)

# Report file path
report_path = os.path.join(
LOCAL_DEVICE_REPORTS.replace("{device_folder}", device.device_folder),
timestamp, "test", device.mac_addr.replace(":", ""))

# Parse string timestamp
date_timestamp: datetime.datetime = datetime.strptime(
timestamp, "%Y-%m-%dT%H:%M:%S")

# Find the report
test_report = None
for report in device.get_reports():
if report.get_started() == date_timestamp:
test_report = report

# This should not happen as the timestamp is checked in api.py first
if test_report is None:
return None

# Copy the original report for comparison
original_report = copy.deepcopy(test_report)

# Update the report with 'additional_info' field
test_report.update_device_profile(device.additional_info)

# Overwrite report only if additional_info has been updated
if original_report.to_json() != test_report.to_json():

# Write the json report
with open(os.path.join(report_path, "report.json"),
"w", encoding="utf-8") as f:
json.dump(test_report.to_json(), f, indent=2)

# Write the html report
with open(os.path.join(report_path, "report.html"),
"w", encoding="utf-8") as f:
f.write(test_report.to_html())

# Write the pdf report
with open(os.path.join(report_path, "report.pdf"),
"wb") as f:
f.write(test_report.to_pdf().getvalue())

# Define temp directory to store files before zipping
results_dir = os.path.join(f"/tmp/testrun/{time.time()}")

Expand Down
Loading