test(job): add multi-day scheduling integration test#68
Merged
bodymindarts merged 7 commits intomainfrom Mar 25, 2026
Merged
Conversation
…clock Verifies that jobs scheduled at 2h, 2d, 4d, and 7d from now all fire correctly when the manual clock is advanced one day at a time. This exercises the polling loop through many intermediate keep-alive and lost-handler wake points, confirming no jobs are missed during large time advances. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…bump Rebase on main brought es-entity 0.10.30 which simplified the clock API from ClockHandle::artificial(ArtificialClockConfig::manual()) to ClockHandle::manual(). Also removes unused JobCompletionResult import. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8bff87a to
884be3e
Compare
- Update ClockHandle::artificial(ArtificialClockConfig::manual()) to ClockHandle::manual() (API simplified in es-entity 0.10.30) - Remove unused JobCompletionResult import - Add explicit jobs.shutdown() to prevent the lost-handler (which uses the far-future manual clock) from resetting other tests' running jobs back to 'pending' via its unfiltered SQL query - Increase wait timeouts and add post-advance sleeps to give the runtime more time to process ~1700 intermediate wake-ups per day-advance - Add detailed doc comments explaining the failure mode and cross-test isolation concerns Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Switch keep-alive and lost-handler loops from clock.sleep() to clock.sleep_coalesce(). During large manual clock advances, these periodic sleepers now wake once at the final time instead of at every intermediate 75s/150s boundary. This eliminates ~1700 DB round-trips per day-advance in tests and fixes polling loop starvation. Bump es-entity to git rev 06e3dd0 (post-0.10.30) which adds the sleep_coalesce() API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The lost-handler SQL has no job_type filter, so its far-future manual clock can reset other tests' running jobs to 'pending' even with sleep_coalesce. Running the multi-day test serially prevents cross-test interference with queue serialization tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
#[serial] only serializes tests that share the attribute. The queue test must also be marked so it never runs concurrently with the multi-day clock test whose lost-handler can reset its running jobs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The lost-handler SQL previously had no job_type filter, so it would reset ALL running jobs across the entire table when their alive_at looked stale. With multiple pollers using different clocks (e.g. manual clock in tests, real clock in production), this caused one poller to incorrectly mark another's jobs as lost. Add AND job_type = ANY($2) to scope dead-job detection to only the job types registered with this poller instance. Also removes serial_test (doesn't work with nextest's per-process isolation) since the root cause is now fixed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
cargo nextest run test_multi_day_scheduling_with_artificial_clockcargo fmtcleancargo clippy --all-targets -- -D warningscleannix flake checkpasses🤖 Generated with Claude Code