jenkinsfile - change from reset after 10 unsuccessful to 5 identical tests, eliminate other counter

This commit is contained in:
matt committed 2026-10-18 04:34:31 -07:00
1 parent d9226469d6
commit 080efd9ddc
1 file changed
+22 -16
+22 -16
View File
@@ -275,7 +275,6 @@ def test(test_count = 0, bt_usb_id = None) -> None:
return -1 return -1
log.info(f"Ensuring BLE active...") log.info(f"Ensuring BLE active...")
test_loop_count = 0 test_loop_count = 0
reset_count = 0
found_macs = scan_macs() found_macs = scan_macs()
log.info("Found these MACs on a scan:") log.info("Found these MACs on a scan:")
log.info(found_macs) log.info(found_macs)
@@ -290,13 +289,25 @@ def test(test_count = 0, bt_usb_id = None) -> None:
log.info("Starting BLE test...") log.info("Starting BLE test...")
log.info(f" Scanning MACs: {mac_list}") log.info(f" Scanning MACs: {mac_list}")
test_list = mac_list test_list = mac_list
# History buffer – keep the last N snapshots (N=5)
history = deque(maxlen=5)
prev_list_snapshot = None
while not test_result: while not test_result:
if test_loop_count > 10: # Check if the failed list has been the same for 5 loops
if prev_list_snapshot is not None and passed_list == prev_list_snapshot:
# List unchanged – add to history
history.append(passed_list)
else:
# List changed – reset history
history.clear()
history.append(current_list)
if len(history) == 5 and all(lst == history[0] for lst in history):
log.warning(f"Last 5 tests have been identical, resetting adapter")
reset_adapter() reset_adapter()
reset_count = reset_count + 1 history.clear()
test_loop_count = 0 prev_list_snapshot = current_list
log.warning("Too many test loops - resetting adapter")
log.info(f" Test run {test_count} loop {reset_count}.{test_loop_count} start. Initializing run...") log.info(f" Test run: {test_count} - loop {test_loop_count} start. Initializing run...")
test_run_results = sensor_data_query(test_list) test_run_results = sensor_data_query(test_list)
test_loop_count = test_loop_count + 1 test_loop_count = test_loop_count + 1
for test_run_result in test_run_results: for test_run_result in test_run_results:
@@ -377,16 +388,11 @@ if __name__ == "__main__":
test_count = test_count + 1 test_count = test_count + 1
this_test_result = [] this_test_result = []
log.info(f"Starting test run {test_count} of {count}") log.info(f"Starting test run {test_count} of {count}")
try: test_label = f"Test {test_count} result"
test_label = f"Test {test_count} result" this_test_result = {
this_test_result = { "test_label": test_label,
"test_label": test_label, "test_result": test(test_count = test_count, bt_usb_id = current_usb_id)
"test_result": test(test_count = test_count, bt_usb_id = current_usb_id) }
}
except Exception as e:
log.error(f"Test failed brah - {e}")
if "org.freedesktop.DBus.Error.AccessDenied" in e:
reset_adapter()
test_results.append(this_test_result) test_results.append(this_test_result)
# Show test results # Show test results
log.info("Test run completed! Summary:") log.info("Test run completed! Summary:")