Skip to content

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

Description

@kcenon

Summary

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

Background

The current test suite relies on time-based waits (e.g., sleep_for(100ms)). This causes two major issues:

  1. Flakiness: Tests fail on busy CI runners if the operation takes longer than the hardcoded wait time.
  2. Slowness: Tests wait longer than necessary (e.g., waiting 100ms for an operation that takes 1ms).

Tasks

Refactor the following files to use std::promise/future, std::condition_variable, or std::latch:

  • integration_tests/failures/error_handling_test.cpp
  • integration_tests/framework/test_helpers.h
  • integration_tests/scenarios/event_bus_integration_test.cpp
  • integration_tests/scenarios/full_system_integration_test.cpp
  • integration_tests/scenarios/runtime_binding_integration_test.cpp
  • integration_tests/stress/stress_test.cpp
  • tests/config_watcher_test.cpp
  • tests/event_bus_failure_test.cpp
  • tests/executor_test.cpp
  • tests/global_logger_registry_test.cpp
  • tests/improved_event_bus_test.cpp
  • tests/thread_safety_tests.cpp
  • tests/unified_bootstrapper_test.cpp

Acceptance Criteria

  • All sleep_for usage in test logic is replaced with synchronization primitives.
  • Tests pass consistently with --gtest_repeat=100.
  • No arbitrary duration constants remain in the synchronization logic (timeouts are allowed for failure safety, but not for control flow).

Metadata

Metadata

Assignees

Labels

refactoringCode refactoring and improvementstestingTesting related issues

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions