Skip to content

test(job): add multi-day scheduling integration test#68

Merged
bodymindarts merged 7 commits intomainfrom
task/multi-day-clock-test-019d20cb
Mar 25, 2026
Merged

test(job): add multi-day scheduling integration test#68
bodymindarts merged 7 commits intomainfrom
task/multi-day-clock-test-019d20cb

Conversation

@bodymindarts
Copy link
Copy Markdown
Member

Summary

  • Adds integration test that verifies multi-day job scheduling with the es-entity manual/artificial clock
  • Creates 5 jobs at different schedule horizons (2h, 2h, 2d, 4d, 7d) and advances clock 1 day at a time over 7 days
  • Asserts each job fires at the correct time and that all jobs complete by the end
  • Exercises polling loop through many intermediate keep-alive (75s) and lost-handler (150s) wake points during large time advances

Test plan

  • Test passes locally with cargo nextest run test_multi_day_scheduling_with_artificial_clock
  • cargo fmt clean
  • cargo clippy --all-targets -- -D warnings clean
  • nix flake check passes

🤖 Generated with Claude Code

bodymindarts and others added 2 commits March 24, 2026 19:45
…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>
@bodymindarts bodymindarts force-pushed the task/multi-day-clock-test-019d20cb branch from 8bff87a to 884be3e Compare March 24, 2026 19:03
bodymindarts and others added 5 commits March 24, 2026 20:30
- 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>
@bodymindarts bodymindarts merged commit 33d38b1 into main Mar 25, 2026
4 checks passed
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