Skip to content

test(refactor): replace sleep_for with synchronization primitives#190

Merged
kcenon merged 1 commit into
mainfrom
feature/issue-188-replace-sleep-for-with-sync-primitives
Dec 8, 2025
Merged

test(refactor): replace sleep_for with synchronization primitives#190
kcenon merged 1 commit into
mainfrom
feature/issue-188-replace-sleep-for-with-sync-primitives

Conversation

@kcenon

@kcenon kcenon commented Dec 8, 2025

Copy link
Copy Markdown
Owner

Summary

Replace std::this_thread::sleep_for with deterministic event-based synchronization primitives to improve test stability and eliminate flakiness.

Changes

  • error_handling_test.cpp: Replace sleep_for(10ms) with wait_for_condition
  • event_bus_integration_test.cpp: Replace 5 sleep_for calls with wait_for_condition using atomic predicates
  • full_system_integration_test.cpp: Replace rate limiters with yield(), waits with wait_for_condition
  • runtime_binding_integration_test.cpp: Replace sleep_for(100μs) with yield()
  • config_watcher_test.cpp: Remove unnecessary sleep, replace rate limiter with yield()

Intentionally Kept

Some sleep_for usages serve specific test purposes:

  • Stress tests (duration-based execution)
  • Mock delay implementations
  • Simulated slow factories for concurrency testing
  • Race condition simulations

Testing

All 92 integration tests pass with --gtest_repeat=10 --gtest_shuffle

Closes #188

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
@kcenon kcenon merged commit a4a8406 into main Dec 8, 2025
19 checks passed
@kcenon kcenon deleted the feature/issue-188-replace-sleep-for-with-sync-primitives branch December 8, 2025 11:28
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(refactor): replace sleep_for with synchronization primitives

1 participant