Skip to content

Conversation

@josefinalliende
Copy link
Contributor

@josefinalliende josefinalliende commented Aug 30, 2025

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

  • 2 sleeps added in integration tests to hopefully fix the issue in master

Summary by CodeRabbit

  • Tests
    • Increased post-action wait time in follow management scenarios to reduce flakiness.
    • Added a brief delay after client initialization in subscription processing to stabilize relay list updates.
    • Aims to improve reliability in asynchronous flows and decrease timing-related test failures in CI.
    • No changes to user-facing functionality; these adjustments solely enhance test stability and consistency.

@josefinalliende josefinalliende marked this pull request as ready for review August 30, 2025 12:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 30, 2025

Walkthrough

In 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

Cohort / File(s) Summary of Changes
Follow management tests
src/integration_tests/test_cases/follow_management/follow_user.rs
Increased post-follow delay from 100ms to 200ms within FollowUserTestCase; no other logic changes.
Subscription processing tests
src/integration_tests/test_cases/subscription_processing/publish_relay_list_update.rs
Inserted a 200ms async sleep after creating the external test client before constructing relay URLs and publishing updates; rest unchanged.

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
Loading
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)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~6 minutes

Poem

A hop, a pause—two hundred ticks,
I twitch my whiskers, watch the mix.
Follow, relay—tests align,
Async dreams in tidy time.
With gentle waits, the burrow hums—
Success arrives on bunny drums. 🥕⏳

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/int-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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 sleep

200ms 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 creation

The 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 24763a5 and cb1fb79.

📒 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.rs
  • src/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

@josefinalliende josefinalliende merged commit 70282b4 into master Aug 30, 2025
4 checks passed
@josefinalliende josefinalliende deleted the fix/int-tests branch August 30, 2025 12:48
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