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

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

Metadata

  • Branch: fix/test-infra/cli-streaming-robust-wait
  • Commit Message: test(cli-streaming): replace time.sleep() with robust synchronization in step_wait_for_completion
  • Milestone: Backlog (see note below)
  • Parent Epic: #2810

Summary

The Behave tests for the CLI streaming functionality in features/steps/cli_streaming_steps.py use time.sleep(0.05) in the step_wait_for_completion function to wait for a command to complete. 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 or a concurrent.futures.Future, to wait for the command to complete.

Subtasks

  • Replace the time.sleep() call in the step_wait_for_completion function with a more robust synchronization mechanism (e.g., threading.Event, concurrent.futures.Future, or a polling loop with a timeout).
  • Ensure that the tests still pass after the changes (nox -e unit_tests).
  • Verify coverage remains >= 97% (nox -e coverage_report).
  • All nox stages pass.

Definition of Done

  • The time.sleep() call in features/steps/cli_streaming_steps.py has been replaced with a robust synchronization mechanism.
  • The tests in features/steps/cli_streaming_steps.py are still passing.
  • The tests are more robust and less prone to flakiness on loaded systems.
  • All nox stages pass.
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.5.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/cli-streaming-robust-wait` - **Commit Message**: `test(cli-streaming): replace time.sleep() with robust synchronization in step_wait_for_completion` - **Milestone**: Backlog (see note below) - **Parent Epic**: #2810 ## Summary The Behave tests for the CLI streaming functionality in `features/steps/cli_streaming_steps.py` use `time.sleep(0.05)` in the `step_wait_for_completion` function to wait for a command to complete. 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` or a `concurrent.futures.Future`, to wait for the command to complete. ## Subtasks - [ ] Replace the `time.sleep()` call in the `step_wait_for_completion` function with a more robust synchronization mechanism (e.g., `threading.Event`, `concurrent.futures.Future`, or a polling loop with a timeout). - [ ] Ensure that the tests still pass after the changes (`nox -e unit_tests`). - [ ] Verify coverage remains >= 97% (`nox -e coverage_report`). - [ ] All nox stages pass. ## Definition of Done - [ ] The `time.sleep()` call in `features/steps/cli_streaming_steps.py` has been replaced with a robust synchronization mechanism. - [ ] The tests in `features/steps/cli_streaming_steps.py` are still passing. - [ ] The tests are more robust and less prone to flakiness on loaded systems. - [ ] All nox stages pass. - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.5.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#3742
No description provided.