TEST-INFRA: [flaky-tests] Replace time.sleep() with a more robust waiting mechanism in devcontainer_health_check tests #3751

Open
opened 2026-04-05 22:28:23 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/test-infra/devcontainer-health-check-flaky-sleep
  • Commit Message: fix(tests): replace time.sleep() with threading.Event in devcontainer_health_check_steps
  • Milestone: (none — backlog)
  • Parent Epic: #1678

Summary

The Behave tests for the devcontainer health check functionality in features/steps/devcontainer_health_check_steps.py use time.sleep(0.05) in two places to wait for the health check thread to start and register. This can lead to flaky tests, especially when running on heavily loaded systems.

Background

Tests that rely on fixed-time waits are often unreliable because the timing of operations can vary depending on the system load and other factors. A better approach is to use a more robust synchronization mechanism, such as a threading.Event, to wait for the health check thread to start and register.

The following instances of time.sleep() have been identified as potential sources of flakiness:

  • step_start_health_check: To give the health check thread a moment to start.
  • step_call_start_health_check: To give the health check thread just enough time to register.

Subtasks

  • Replace the time.sleep() calls in step_start_health_check and step_call_start_health_check with a threading.Event-based synchronization mechanism.
  • Ensure that the tests still pass after the changes.
  • Verify all nox stages pass.

Definition of Done

  • The time.sleep() calls in features/steps/devcontainer_health_check_steps.py have been replaced with a threading.Event-based synchronization mechanism.
  • The tests in features/steps/devcontainer_health_check_steps.py are still passing.
  • The tests are more robust and less prone to flakiness.
  • All nox stages pass.
  • Coverage >= 97%

Duplicate Check

  • Searched for issues with keywords: flaky, time.sleep, devcontainer
  • 0 results found.
  • This issue is not a duplicate.

Backlog note: This issue was discovered during autonomous operation
on milestone v3.7.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/test-infra/devcontainer-health-check-flaky-sleep` - **Commit Message**: `fix(tests): replace time.sleep() with threading.Event in devcontainer_health_check_steps` - **Milestone**: _(none — backlog)_ - **Parent Epic**: #1678 ## Summary The Behave tests for the devcontainer health check functionality in `features/steps/devcontainer_health_check_steps.py` use `time.sleep(0.05)` in two places to wait for the health check thread to start and register. This can lead to flaky tests, especially when running on heavily loaded systems. ## Background Tests that rely on fixed-time waits are often unreliable because the timing of operations can vary depending on the system load and other factors. A better approach is to use a more robust synchronization mechanism, such as a `threading.Event`, to wait for the health check thread to start and register. The following instances of `time.sleep()` have been identified as potential sources of flakiness: - `step_start_health_check`: To give the health check thread a moment to start. - `step_call_start_health_check`: To give the health check thread just enough time to register. ## Subtasks - [ ] Replace the `time.sleep()` calls in `step_start_health_check` and `step_call_start_health_check` with a `threading.Event`-based synchronization mechanism. - [ ] Ensure that the tests still pass after the changes. - [ ] Verify all nox stages pass. ## Definition of Done - [ ] The `time.sleep()` calls in `features/steps/devcontainer_health_check_steps.py` have been replaced with a `threading.Event`-based synchronization mechanism. - [ ] The tests in `features/steps/devcontainer_health_check_steps.py` are still passing. - [ ] The tests are more robust and less prone to flakiness. - [ ] All nox stages pass. - [ ] Coverage >= 97% ### Duplicate Check - Searched for issues with keywords: `flaky`, `time.sleep`, `devcontainer` - 0 results found. - This issue is not a duplicate. > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.7.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#3751
No description provided.