mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 06:33:51 +00:00
Merge branch 'heap_scheduler_stress_component' into integration
This commit is contained in:
@@ -36,26 +36,35 @@ void SchedulerBulkCleanupComponent::trigger_bulk_cleanup() {
|
||||
// At this point we have 25 items marked for removal
|
||||
// The next scheduler.call() should trigger the bulk cleanup path
|
||||
|
||||
// Schedule an interval that will execute multiple times to ensure cleanup happens
|
||||
// The bulk cleanup should happen on the next scheduler.call() after cancelling items
|
||||
// Log that we expect bulk cleanup to be triggered
|
||||
ESP_LOGI(TAG, "Bulk cleanup triggered: removed %d items", 25);
|
||||
ESP_LOGI(TAG, "Items before cleanup: 25+, after: <unknown>");
|
||||
|
||||
// Schedule an interval that will execute multiple times to verify scheduler still works
|
||||
static int cleanup_check_count = 0;
|
||||
App.scheduler.set_interval(this, "cleanup_checker", 25, [this]() {
|
||||
cleanup_check_count++;
|
||||
ESP_LOGI(TAG, "Cleanup check %d - scheduler still running", cleanup_check_count);
|
||||
|
||||
if (cleanup_check_count >= 5) {
|
||||
// Cancel the interval and complete the test
|
||||
// Cancel the interval
|
||||
App.scheduler.cancel_interval(this, "cleanup_checker");
|
||||
ESP_LOGI(TAG, "Bulk cleanup triggered: removed %d items", 25);
|
||||
ESP_LOGI(TAG, "Items before cleanup: 25+, after: <unknown>");
|
||||
ESP_LOGI(TAG, "Bulk cleanup test complete");
|
||||
ESP_LOGI(TAG, "Scheduler verified working after 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");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user