Skip to content

test(auth): wait on the recorded request instead of a fixed sleep - #4194

Merged
kixelated merged 2 commits into
mainfrom
claude/moq-auth-settle
Sep 25, 2026
Merged

kixelated merged 2 commits into
mainfrom
claude/moq-auth-settle

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

The moq-auth client tests used settle() (a fixed 50ms sleep) to wait for the background end POST to reach the mock server. On a loaded runner the POST lands later, so client::tests::a_bare_drop_ends_as_dropped failed with expected a dropped end, got Connect (seen in #4190's Test job).

Approach

  • The test Log is now a kio::Shared<Vec<Request>>. Log::until awaits a predicate over the recorded requests, and Log::end waits for the end POST and returns it. settle() is gone.
  • The 10ms polling loops in the nudge tests use Log::until too.
  • a_nudge_during_inflight_... used to check for "no third POST" by sleeping. It now waits for both re-check replies to land, closes, waits for end, and asserts exactly two re-checks.
  • Removed a_nudge_during_backoff_posts_at_once. Its sleep was waiting for a 503 to land, which the test can't observe. Backoff also leaves the driver in the same state as idle (nothing in flight, timer armed), which a_nudge_while_idle_posts_at_once already covers. And its 2s timeout was longer than the ~1s first backoff, so it would have passed even if nudges were ignored.

Stress run: 20 iterations of client::tests with every core pinned, all passing. The old code also passed 20/20 locally, so this box couldn't reproduce the CI flake. The fix removes the timing assumption rather than depending on one.

Impact

  • Tests only. No public API or wire change.

Alternatives

  • A longer sleep or a retry. Ruled out by repo policy; it would only move the race.

Follow-ups

  • None.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

The client tests slept 50ms for the background end POST to reach the mock
server, which lost the race on a loaded CI runner. The request log is now a
kio::Shared, so tests await the request itself.

Drops a_nudge_during_backoff_posts_at_once: backoff leaves the driver in the
same state as idle, and its 2s timeout outlasted the ~1s backoff, so it could
not fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review September 25, 2026 21:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-09-25T22:50:45.186841Z fe167d1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 18b8b457-1455-48de-b06b-8c9b88304e2a

📥 Commits

Reviewing files that changed from the base of the PR and between 1140237 and fe167d1.

📒 Files selected for processing (1)
  • rs/moq-auth/src/client.rs

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

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ff2cec844

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rs/moq-auth/src/client.rs Outdated
Comment on lines +627 to +631
for _ in 0..2 {
tokio::time::timeout(Duration::from_secs(3), consumer.changed())
.await
.expect("the in-flight nudge POSTs once more when the reply lands")
.unwrap();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Track each reply instead of consuming coalesced grant changes

On a loaded runner that does not reschedule this test within the mock's 400 ms delay, both revalidation replies can update the lease before the first consumer.changed() resumes. Consumer::poll_changed then advances seen directly to the latest epoch, so the two updates coalesce into one observation and the second loop iteration times out even though exactly two POSTs occurred. Use a non-coalescing reply counter or barrier to wait for the two distinct completions rather than introducing another scheduling-dependent test failure.

AGENTS.md reference: AGENTS.md:L15-L18

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. The test now waits until the request log has two revalidate POSTs, then still asserts the count stays at two after the session ends.

(Written by Grok 4.7)

changed() jumps to the latest grant epoch, so two replies can land as one
observation and the inflight nudge test times out even when both POSTs
happened. Wait on the request log, which records each one.

Co-authored-by: Grok 4.7 <noreply@x.ai>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Landing this on main. The auth client tests wait on the recorded request instead of a fixed sleep. The inflight nudge test counts revalidate POSTs on that log, because changed() jumps to the latest grant epoch and can hide the second reply.

(Written by Grok 4.7)

@kixelated
kixelated enabled auto-merge (squash) September 25, 2026 22:49
@kixelated
kixelated merged commit 1f2e40c into main Sep 25, 2026
3 checks passed
@kixelated
kixelated deleted the claude/moq-auth-settle branch September 25, 2026 23:13
This was referenced Sep 25, 2026
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.

1 participant