Skip to content

Add deterministic scheduler interval regression tests - #5609

Open
samrusani wants to merge 2 commits into
clockworklabs:masterfrom
samrusani:agent/scheduler-interval-regression-test
Open

Add deterministic scheduler interval regression tests#5609
samrusani wants to merge 2 commits into
clockworklabs:masterfrom
samrusani:agent/scheduler-interval-regression-test

Conversation

@samrusani

@samrusani samrusani commented Jul 28, 2026

Copy link
Copy Markdown

Description of Changes

Closes #5591.

  • Retain the original scheduled call time across reducer execution and cleanup through a private execution/reschedule seam.
  • Add deterministic coverage that simulates completion 30 seconds later and proves the next interval is based on the pre-execution call time.
  • Keep one-shot schedules and procedure/error-path rescheduling behavior unchanged, without sleeps or wall-clock tolerances.

API and ABI breaking changes

None.

Expected complexity level and risk

  1. This is an internal testability refactor with no public behavior or API change.

Testing

  • cargo fmt --all -- --check
  • cargo test -p spacetimedb-core reducer_reschedules_from_call_time_not_completion_time
  • cargo test -p spacetimedb-core host::scheduler::tests
  • cargo test -p spacetimedb-core --lib (151 passed)
  • cargo clippy -p spacetimedb-core --all-targets -- -D warnings
  • git diff --check
  • Temporarily restored completion-time rescheduling; the focused regression test failed as expected, then passed after restoring call-time rescheduling.

@samrusani
samrusani marked this pull request as ready for review July 28, 2026 14:18
Comment thread crates/core/src/host/scheduler.rs Outdated
let previous_timestamp = Timestamp::from_micros_since_unix_epoch(1_000_000);
let previous_instant = Instant::now();

let reschedule = interval_reschedule(interval.into(), (previous_timestamp, previous_instant)).unwrap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

interval_reschedule method is too trivial to test. I don't think these tests are really testing anything good.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed — the helper-only assertion did not cover the execution boundary. I replaced it in 6d01046 with a seam used by the actual scheduled-reducer path: the test simulates completion 30 seconds after the captured call time and verifies that both reschedule timestamps still advance from the call time. As a mutation check, temporarily restoring completion-time rescheduling makes the focused test fail; after restoring call-time rescheduling, the focused test, all 151 core library tests, formatting, and clippy pass.

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.

Regression test for scheduling interval reducers

2 participants