Skip to content

Add Manual Scheduler to Remove Test Sleeps #3869

Description

@alexanderkiel

Part of the effort to eliminate all Thread/sleep calls from tests (see #3863 and PR #3866).

Several tests sleep to wait for work started by blaze.scheduler (schedule-at-fixed-rate / submit). Analogous to :blaze.test/manual-executor (PR #3866), a manual scheduler test double where the test triggers ticks deterministically would remove these sleeps:

  • modules/openid-auth/test/blaze/openid_auth_test.clj:155,161,167 — JWKS keys are fetched at a fixed rate; each site sleeps 2000 ms
  • modules/openid-client/test/blaze/openid_client/token_provider_test.clj:188,197,206,218 — busy-wait polling loops with 10 ms sleeps around the scheduled token fetch
  • modules/page-id-cipher/test/blaze/page_id_cipher_test.clj:204 — key rotation is scheduled at a fixed rate; the test sleeps 1500 ms
  • modules/jvm-metrics-logger/test/blaze/jvm_metrics_logger_test.clj:70,81 — scheduled metrics logging; sleeps 200 ms
  • modules/db/test/blaze/db/node_test.clj:356 — the patient-last-change index build is submitted via sched/submit on node start (node.clj:608); the test sleeps 100 ms

Special case: modules/scheduler/test/blaze/scheduler_test.clj:29,34 tests the timing behaviour of the real scheduler itself, so a double is not applicable there — restructure with a latch/counter awaited with a timeout instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions