-
Notifications
You must be signed in to change notification settings - Fork 36
test: add sleep to failing integration test #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughIn two integration tests, asynchronous delays were adjusted: FollowUserTestCase increased a post-follow sleep to 200ms, and PublishRelayListUpdateTestCase added a 200ms sleep after client creation. No other logic, control flow, or public APIs were changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant T as FollowUserTestCase
participant A as AccountService
T->>A: fetch_follower_account()
T->>A: follow_user(target)
Note over T: Sleep 200ms (post-follow delay)
T->>A: is_following_user(target)
A-->>T: boolean
sequenceDiagram
autonumber
participant T as PublishRelayListUpdateTestCase
participant C as ExternalTestClient
participant R as RelayService
T->>C: create_client()
Note over T: Sleep 200ms (post-client creation)
T->>R: publish_relay_list(relay_urls)
R-->>T: ack
T->>R: publish_nip65_update()
R-->>T: ack
Note over T: existing final sleep (unchanged)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~6 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/integration_tests/test_cases/follow_management/follow_user.rs (1)
38-38: Deflake by polling with timeout instead of a fixed 200ms sleep200ms can still be racy on slower Ubuntu runners. Poll until the follow is observable (with a cap) to make the test deterministic.
- // Add small delay for async operations - tokio::time::sleep(tokio::time::Duration::from_millis(200)).await; - - let is_following = context - .whitenoise - .is_following_user(account, &self.target_pubkey) - .await?; + // Wait up to 5s for follow to be processed; poll every 50ms. + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + let mut is_following = false; + while std::time::Instant::now() < deadline { + is_following = context + .whitenoise + .is_following_user(account, &self.target_pubkey) + .await?; + if is_following { + break; + } + tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; + }If you prefer to keep the sleep as a hotfix, add a brief comment explaining it mitigates Ubuntu CI flakiness from PR #336/#339 and follow up with a polling helper in a subsequent PR.
src/integration_tests/test_cases/subscription_processing/publish_relay_list_update.rs (1)
43-45: Wait for readiness via retry instead of fixed 200ms sleep after client creationThe connection handshake can exceed 200ms on CI. Retrying the publish for a bounded period removes timing assumptions and reduces flakes.
- tokio::time::sleep(tokio::time::Duration::from_millis(200)).await; - let relay_urls: Vec<String> = dev_relay_urls.iter().map(|url| url.to_string()).collect(); - publish_relay_lists(&test_client, relay_urls).await?; + let relay_urls: Vec<String> = dev_relay_urls.iter().map(|url| url.to_string()).collect(); + // Retry publish for up to 5s to allow client connections to become ready. + let start = std::time::Instant::now(); + loop { + match publish_relay_lists(&test_client, relay_urls.clone()).await { + Ok(_) => break, + Err(e) if start.elapsed() < std::time::Duration::from_secs(5) => { + tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; + } + Err(e) => return Err(e), + } + }If a readiness API exists (e.g., waiting for N connected relays or an auth/EOSE signal), prefer that over retries. Otherwise, this keeps the test robust without over-sleeping.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/integration_tests/test_cases/follow_management/follow_user.rs(1 hunks)src/integration_tests/test_cases/subscription_processing/publish_relay_list_update.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/integration_tests/**
📄 CodeRabbit inference engine (.cursor/rules/mls-protocol-docs.mdc)
Place MLS integration tests under src/integration_tests
Files:
src/integration_tests/test_cases/follow_management/follow_user.rssrc/integration_tests/test_cases/subscription_processing/publish_relay_list_update.rs
🧠 Learnings (2)
📚 Learning: 2025-08-23T16:27:41.511Z
Learnt from: jgmontoya
PR: parres-hq/whitenoise#324
File: src/integration_tests/test_cases/subscription_processing/publish_metadata_update.rs:42-45
Timestamp: 2025-08-23T16:27:41.511Z
Learning: In Whitenoise integration tests, using `unwrap()` on `test_client.add_relay()` for dev relay connections is acceptable since these are controlled test environments where failing fast is preferred over complex error handling.
Applied to files:
src/integration_tests/test_cases/subscription_processing/publish_relay_list_update.rs
📚 Learning: 2025-08-23T16:23:47.066Z
Learnt from: jgmontoya
PR: parres-hq/whitenoise#324
File: src/integration_tests/test_cases/subscription_processing/publish_metadata_update.rs:35-39
Timestamp: 2025-08-23T16:23:47.066Z
Learning: In the Whitenoise integration test framework, using `unwrap()` on `RelayUrl::parse()` for the hardcoded dev_relays URLs (ws://localhost:8080 and ws://localhost:7777) is acceptable since these are known, controlled addresses in the test environment where failing fast is preferred.
Applied to files:
src/integration_tests/test_cases/subscription_processing/publish_relay_list_update.rs
Context
In #336 checks were passing but in master integrations tests failed in ubuntu. Sometimes integration tests need some sleep 😴 😅 and in theat PR I removed one sleep that apparently was necessary in the publish relays list test case.
Also, locally, I was having trouble with the follows scenario in the integration tests, and now I noticed that a longer sleep there fixed my issue too
What has been done
Summary by CodeRabbit