Skip to content

fix(engine): replace fixed sleeps with polling in backpressure tests#370

Merged
streamer45 merged 1 commit intomainfrom
devin/1777118186-fix-backpressure-test-flakiness
Apr 25, 2026
Merged

fix(engine): replace fixed sleeps with polling in backpressure tests#370
streamer45 merged 1 commit intomainfrom
devin/1777118186-fix-backpressure-test-flakiness

Conversation

@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor

Summary

The test_dynamic_connection_under_backpressure test uses a fixed 100ms sleep before asserting the pacer node reached Running state. On slow CI runners (e.g. this run) the node lifecycle (Creating → Initializing → Running) takes ~206ms, causing the assertion to fire before the node is ready.

This PR replaces all fixed sleep + assert patterns across all three backpressure tests with a wait_for_states polling helper — the same pattern already used in the async_node_creation test suite (crates/engine/src/tests/async_node_creation.rs:252). Each call polls get_node_states() every 20ms with a 5-second timeout, eliminating timing-dependent flakiness.

Changes:

  • Add wait_for_states polling helper to backpressure.rs
  • test_backpressure_no_deadlock: replace 500ms sleep + two separate asserts with a single poll for both reader and pacer states
  • test_dynamic_connection_under_backpressure: replace 100ms sleep + assert with poll for pacer=Running
  • test_node_removal_under_backpressure: replace 100ms sleep with poll for pacer to leave Creating state before removal

Review & Testing Checklist for Human

  • Verify the wait_for_states helper matches the established pattern in async_node_creation.rs (same poll interval, same signature)
  • Run cargo test -p streamkit-engine --test backpressure locally to confirm all 3 tests pass
  • Optionally run the tests several times in quick succession to confirm no flakiness remains

Notes

The root cause was visible in the CI logs — the pacer's Running state update arrived at 11:53:31.158672Z, but the 100ms sleep (started after send_control returned at ~11:53:30.952Z) expired at ~11:53:31.052Z — about 107ms too early.

Link to Devin session: https://staging.itsdev.in/sessions/8a81ffd549e742f8a209ff82586c27f6
Requested by: @streamer45

The test_dynamic_connection_under_backpressure test used a fixed 100ms
sleep before asserting the pacer node reached Running state. On slow CI
runners the node lifecycle (Creating → Initializing → Running) takes
longer than 100ms, causing sporadic assertion failures.

Replace all fixed sleep + assert patterns across the three backpressure
tests with a wait_for_states polling helper (same pattern used in the
async_node_creation test suite). Each call polls get_node_states() every
20ms with a 5-second timeout, eliminating timing-dependent flakiness.

Signed-off-by: StreamKit Devin <devin@streamkit.dev>
Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor Author

staging-devin-ai-integration Bot commented Apr 25, 2026

✅ Reviewed on 817bce1

View review

@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor Author

@staging-devin-ai-integration staging-devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review (Staging)
Debug

Playground

@streamer45 streamer45 merged commit 084f871 into main Apr 25, 2026
16 checks passed
@streamer45 streamer45 deleted the devin/1777118186-fix-backpressure-test-flakiness branch April 25, 2026 12:11
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.

2 participants