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
2 changes: 1 addition & 1 deletion framework/python/src/common/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _get_default_config(self):
'log_level': 'INFO',
'startup_timeout': 60,
'monitor_period': 30,
'max_device_reports': 5,
'max_device_reports': 0,
'api_url': 'http://localhost',
'api_port': 8000
}
Expand Down
53 changes: 27 additions & 26 deletions framework/python/src/test_orc/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,32 +190,33 @@ def _cleanup_old_test_results(self, device):
else:
max_device_reports = self._session.get_max_device_reports()

completed_results_dir = os.path.join(
self._root_path,
LOCAL_DEVICE_REPORTS.replace("{device_folder}", device.device_folder))

completed_tests = os.listdir(completed_results_dir)
cur_test_count = len(completed_tests)
if cur_test_count > max_device_reports:
LOGGER.debug("Current device has more than max tests results allowed: " +
str(cur_test_count) + ">" + str(max_device_reports))

# Find and delete the oldest test
oldest_test = self._find_oldest_test(completed_results_dir)
if oldest_test is not None:
LOGGER.debug("Oldest test found, removing: " + str(oldest_test[1]))
shutil.rmtree(oldest_test[1], ignore_errors=True)

# Remove oldest test from session
oldest_timestamp = oldest_test[0]
self.get_session().get_target_device().remove_report(oldest_timestamp)

# Confirm the delete was succesful
new_test_count = len(os.listdir(completed_results_dir))
if (new_test_count != cur_test_count
and new_test_count > max_device_reports):
# Continue cleaning up until we're under the max
self._cleanup_old_test_results(device)
if max_device_reports > 0:
completed_results_dir = os.path.join(
self._root_path,
LOCAL_DEVICE_REPORTS.replace("{device_folder}", device.device_folder))

completed_tests = os.listdir(completed_results_dir)
cur_test_count = len(completed_tests)
if cur_test_count > max_device_reports:
LOGGER.debug("Current device has more than max tests results allowed: " +
str(cur_test_count) + ">" + str(max_device_reports))

# Find and delete the oldest test
oldest_test = self._find_oldest_test(completed_results_dir)
if oldest_test is not None:
LOGGER.debug("Oldest test found, removing: " + str(oldest_test[1]))
shutil.rmtree(oldest_test[1], ignore_errors=True)

# Remove oldest test from session
oldest_timestamp = oldest_test[0]
self.get_session().get_target_device().remove_report(oldest_timestamp)

# Confirm the delete was succesful
new_test_count = len(os.listdir(completed_results_dir))
if (new_test_count != cur_test_count
and new_test_count > max_device_reports):
# Continue cleaning up until we're under the max
self._cleanup_old_test_results(device)

def _find_oldest_test(self, completed_tests_dir):
oldest_timestamp = None
Expand Down
2 changes: 1 addition & 1 deletion local/system.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"log_level": "INFO",
"startup_timeout": 60,
"monitor_period": 300,
"max_device_reports": 5
"max_device_reports": 0
}