From 731613421d553223658ababcf42e774c047ef1f5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 6 Jul 2025 20:59:08 -0500 Subject: [PATCH] fix flakey --- .../scheduler_bulk_cleanup_component.cpp | 10 ++++++++-- tests/integration/test_scheduler_bulk_cleanup.py | 13 ++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/integration/fixtures/external_components/scheduler_bulk_cleanup_component/scheduler_bulk_cleanup_component.cpp b/tests/integration/fixtures/external_components/scheduler_bulk_cleanup_component/scheduler_bulk_cleanup_component.cpp index 5d74d1dff8..688dd2d13d 100644 --- a/tests/integration/fixtures/external_components/scheduler_bulk_cleanup_component/scheduler_bulk_cleanup_component.cpp +++ b/tests/integration/fixtures/external_components/scheduler_bulk_cleanup_component/scheduler_bulk_cleanup_component.cpp @@ -52,10 +52,16 @@ void SchedulerBulkCleanupComponent::trigger_bulk_cleanup() { }); // Also schedule some normal timeouts to ensure scheduler keeps working after cleanup + static int post_cleanup_count = 0; for (int i = 0; i < 5; i++) { std::string name = "post_cleanup_" + std::to_string(i); - App.scheduler.set_timeout(this, name, 50 + i * 25, - [i]() { ESP_LOGI(TAG, "Post-cleanup timeout %d executed correctly", i); }); + App.scheduler.set_timeout(this, name, 50 + i * 25, [i]() { + ESP_LOGI(TAG, "Post-cleanup timeout %d executed correctly", i); + post_cleanup_count++; + if (post_cleanup_count >= 5) { + ESP_LOGI(TAG, "All post-cleanup timeouts completed - test finished"); + } + }); } } diff --git a/tests/integration/test_scheduler_bulk_cleanup.py b/tests/integration/test_scheduler_bulk_cleanup.py index 07f68e3d63..08ff293b84 100644 --- a/tests/integration/test_scheduler_bulk_cleanup.py +++ b/tests/integration/test_scheduler_bulk_cleanup.py @@ -64,14 +64,13 @@ async def test_scheduler_bulk_cleanup( match = re.search(r"Post-cleanup timeout (\d+) executed correctly", line) if match: post_cleanup_executed += 1 - # All 5 post-cleanup timeouts have executed - if post_cleanup_executed >= 5 and not test_complete_future.done(): - test_complete_future.set_result(None) - # Check for bulk cleanup completion (but don't end test yet) - if "Bulk cleanup test complete" in line: - # This just means the interval finished, not that all timeouts executed - pass + # Check for final test completion + if ( + "All post-cleanup timeouts completed - test finished" in line + and not test_complete_future.done() + ): + test_complete_future.set_result(None) async with ( run_compiled(yaml_config, line_callback=on_log_line),