Skip to content

Replace Race Simulation Sleeps With Latches #3872

Description

@alexanderkiel

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

Several tests sleep to make a race or interleaving probable; latch/promise based coordination makes it guaranteed:

  • modules/interaction/test/blaze/interaction/update_test.clj:267,523 and modules/interaction/test/blaze/interaction/transaction_test.clj:594,1439 — a kv/put! redef sleeps 20 ms so that a concurrent transaction interleaves
  • modules/job-async-interaction/test/blaze/job/async_interaction_test.clj:321 — the test batch handler sleeps 100 ms so cancellation can arrive first
  • modules/thread-pool-executor-collector/test/blaze/thread_pool_executor_collector_test.clj:89,90 — a task sleeps 500 ms to appear "active" and the test sleeps 100 ms to wait for it to start; block on a latch and signal the start instead
  • modules/job-scheduler/test/blaze/job_scheduler_test.clj:693 — sleeps 100 ms so the TaskSubscriber fails; needs a deterministic signal
  • modules/executor/test/blaze/executors_test.clj:35,63,70,77,86 — execute-then-sleep-then-assert on real pools; deliver a promise from the task and deref with timeout instead
  • modules/kv/test/blaze/db/kv/iter_pool_test.clj:266 — random jitter in a concurrency stress test; can simply be removed
  • modules/db/test/blaze/db/node_test.clj:279,295,321 — sleeps 100 ms before tx-result to hit the "result already available" path; @(d/sync node t) before calling tx-result achieves this deterministically

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