test(refactor): replace sleep_for with synchronization primitives#190
Merged
kcenon merged 1 commit intoDec 8, 2025
Merged
Conversation
Replace std::this_thread::sleep_for with deterministic event-based
synchronization primitives to improve test stability and eliminate flakiness.
Changes:
- integration_tests/failures/error_handling_test.cpp:
- Replace sleep_for(10ms) with wait_for_condition for event processing
- integration_tests/scenarios/event_bus_integration_test.cpp:
- Replace 5 sleep_for(10ms) calls with wait_for_condition using
atomic predicates
- Use yield() for unsubscribe verification (negative test)
- integration_tests/scenarios/full_system_integration_test.cpp:
- Replace 2 sleep_for(1ms) rate limiters with yield()
- Replace 2 sleep_for(50ms) waits with wait_for_condition
- integration_tests/scenarios/runtime_binding_integration_test.cpp:
- Replace sleep_for(100μs) with yield() for thread coordination
- tests/config_watcher_test.cpp:
- Remove unnecessary sleep before file modification test
- Replace sleep_for(1ms) rate limiter with yield()
The following sleep_for usages were intentionally kept as they serve
specific test purposes:
- Stress tests with intentional duration-based execution
- Mock executor delay implementations
- Simulated slow factory calls for concurrency testing
- Race condition simulation for shutdown tests
Verified: All 92 integration tests pass with --gtest_repeat=10
5 tasks
kcenon
added a commit
that referenced
this pull request
Apr 13, 2026
…) (#190) Replace std::this_thread::sleep_for with deterministic event-based synchronization primitives to improve test stability and eliminate flakiness. Changes: - integration_tests/failures/error_handling_test.cpp: - Replace sleep_for(10ms) with wait_for_condition for event processing - integration_tests/scenarios/event_bus_integration_test.cpp: - Replace 5 sleep_for(10ms) calls with wait_for_condition using atomic predicates - Use yield() for unsubscribe verification (negative test) - integration_tests/scenarios/full_system_integration_test.cpp: - Replace 2 sleep_for(1ms) rate limiters with yield() - Replace 2 sleep_for(50ms) waits with wait_for_condition - integration_tests/scenarios/runtime_binding_integration_test.cpp: - Replace sleep_for(100μs) with yield() for thread coordination - tests/config_watcher_test.cpp: - Remove unnecessary sleep before file modification test - Replace sleep_for(1ms) rate limiter with yield() The following sleep_for usages were intentionally kept as they serve specific test purposes: - Stress tests with intentional duration-based execution - Mock executor delay implementations - Simulated slow factory calls for concurrency testing - Race condition simulation for shutdown tests Verified: All 92 integration tests pass with --gtest_repeat=10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
std::this_thread::sleep_forwith deterministic event-based synchronization primitives to improve test stability and eliminate flakiness.Changes
sleep_for(10ms)withwait_for_conditionsleep_forcalls withwait_for_conditionusing atomic predicatesyield(), waits withwait_for_conditionsleep_for(100μs)withyield()yield()Intentionally Kept
Some
sleep_forusages serve specific test purposes:Testing
All 92 integration tests pass with
--gtest_repeat=10 --gtest_shuffleCloses #188