Test freshness and lease expiration as half-open time intervals
Distinguish lease ownership from mere lease existence
Use mutation thinking instead of sleeps and probabilistic repetition
Time boundaries are part of the protocol
A cache contract must say what happens at the exact deadline. Modeling freshness and lease validity as half-open intervals makes the rule unambiguous: a value is fresh while now < fresh_until, and a lease is live while now < lease_until. Injected logical time turns those boundaries into fast, reproducible tests.
Ownership changes the stale-state decision
After data becomes stale, the owner of a live refresh lease may continue the refresh while other callers wait or serve an explicitly allowed stale value. Lease existence alone is insufficient: tests must distinguish the owner, a foreign caller, an expired lease and no lease. A lease still does not replace fencing or a source-of-truth write invariant.
Mutation tests measure discrimination
A compact suite is valuable when plausible wrong implementations cannot survive it. Inclusive deadlines, checking the lease before freshness and ignoring owner identity are realistic changes that ordinary happy-path tests often miss. Killing each mutant provides stronger evidence than running the same race thousands of times.
CHECKPOINT
Which two techniques make a cache-lease concurrency test deterministic and diagnostically useful?
Select every applicable option. Credit requires an exact set match.
ISOLATED RUST 1.96
tests/cache-lease-cases.rsEDIT
02 / TEST DESIGN
Design strong tests
Complete the table-driven suite returned by `cases`. Your cases must match the documented cache decision contract and reject four realistic mutants: inclusive freshness, inclusive lease validity, ignored owner identity and lease-first evaluation.