Skip to content

test(deliveries): worker tests await their attempts and idle polls instead of polling and sleeping - #697

Open
PiquelChips wants to merge 1 commit into
mainfrom
test/deliveries-waits
Open

PiquelChips wants to merge 1 commit into
mainfrom
test/deliveries-waits

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Delivery worker tests found out what the workers had done by listing the database every 50ms. One of them also slept two full poll intervals (2s) so that an idle poll would happen. They now await what the workers report as it happens, which also makes them faster.

Independent of the other PRs in this series; based on main.

Changes

  • Production (a test-only signal): Sender gets a #[cfg(test)] fn idle(&self) {} hook. A worker calls it whenever its poll finds nothing due. It does not exist outside tests.
  • The test Recorder publishes a Seen { attempts, idle } in a watch: each attempt's delivery ID as its send starts, and a count of idle polls.
  • wait_for now awaits that watch instead of listing the database. Once it returns, the test shuts the workers down, which finishes any attempt in progress and records its outcome. Then the test reads the delivery once with listed and asserts as before.

Tests

  • workers_retry_retryable_errors_and_fail_permanent_ones: waits for both deliveries' attempts, shuts down, then asserts the same statuses, errors, backoff and attempt IDs.
  • each_attempt_is_a_trace_and_idle_polls_export_nothing: waits for the attempt and then for an idle poll after it, instead of sleeping two intervals. It now also checks that the delivery failed. Checked: with the worker loop running inside a span, which makes idle polls export, the test fails.
  • a_resent_delivery_carries_the_same_id: the first replica sends, is shut down, and the delivery reads as failed. After the operator retries, a second replica sends it again. The test asserts the same two attempts with one ID, and success.
  • a_delivery_survives_its_replica_dying_mid_send: waits for B's send, then shuts B down, which records its success, before releasing A. So A's late refusal still arrives after B's success, as before, and must be discarded. The test asserts the same lease, ID and outcome.

I ran the 4 tests five times against a scratch cluster, and they passed every time.

Council review

Rounds: 2

Delegate Round 1 Round 2
GPT 6.1 Sol no score no score
Claude Opus 5.5 8/10 9/10
Claude Fable 5.2 8/10 8/10

GPT 6.1 Sol could not take part: its account hit its usage limit.

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 and Claude Fable 5.2 (via T3 Code)

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a5a32fa-bba1-465d-91f6-9dba436efbeb
Commits

Reviewing files that changed from the base of the PR and between e99cc0e and 4b9b5b5.

Files selected for processing: 2

  • apps/auth-service/src/deliveries/mod.rs
  • apps/auth-service/src/deliveries/tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@PiquelChips
PiquelChips marked this pull request as ready for review November 22, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

1 participant