Skip to content

test(jobs): job tests await their runs and each other's exclusions instead of sleeping - #694

Open
PiquelChips wants to merge 1 commit into
test/audit-waitsfrom
test/jobs-waits
Open

PiquelChips wants to merge 1 commit into
test/audit-waitsfrom
test/jobs-waits

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

The job runner's tests polled a counter and a log every 5 to 20ms. Its exclusivity test went further: it held its lock for a fixed 100ms and hoped the other runner would try to take it in that time. Each one now awaits the event it is waiting for. The exclusivity test now proves that every run kept the other runner out, where before it only hoped so.

Stacked on #693.

Changes

  • Production (a test-only signal): ExclusiveJob gets a #[cfg(test)] fn excluded(&self) {} hook. The runner calls it whenever it finds another replica running the job. It does not exist outside tests.
  • Log keeps its events in a watch channel, so waiting on it is an await rather than a poll.

Tests

  • a_panicking_run_releases_its_lock_and_the_job_runs_again: the runs are counted in a watch, and the test awaits the second run, where it used to poll an AtomicU32.
  • runners_never_overlap_and_a_dropped_holder_hands_over: Held holds its lock until the other runner has been excluded at least once since the run started (or until shutdown), where it used to sleep 100ms. The test then checks the same things on the run events, with exclusions filtered out. Checked: with try_exclusive always succeeding, the test fails with [Started(0), Started(1)].
  • cleanup_that_keeps_falling_behind_raises_its_alert and cleanup_that_keeps_failing_raises_its_alert: they wait for cleanup's lock with Database::exclusive and drop the cleanup_lock polling helper.

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

Council review

Rounds: 3

Delegate Round 1 Round 2 Round 3
GPT 6.1 Sol no score no score no score
Claude Opus 5.5 8/10 9/10 9/10
Claude Fable 5.2 8/10 8/10 9/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

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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: 82c68cdc-e8fd-49f4-8563-8f4b0210c445

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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