Repository navigation
Studio: stop sleeping in the API-key expiry cache test - #10260
Souravrajvi0 wants to merge 1 commit into
Conversation
test_cache_does_not_bypass_expiry minted a key that expired in 600 ms and then slept. Under parallel CI that window could elapse before the first assertion, which is the flake recorded on unslothai#10147. Drive storage.datetime.now instead so the cached hash still re-checks expires_at without depending on wall-clock timing.
|
main now removes that sleep in studio/backend/tests/test_api_key_expiry.py by expiring the key row after the cache is warmed, so I do not think this is needed any more. Sorry for the slow review, and thanks for putting it together. |
|
Thanks for the PR! Closing this as superseded by #10952, which is now on main. That change removes the 600 ms TTL and the sleep from |
Summary
Part of #10147 (the flaky-test follow-up from #10076).
tests/test_api_key_expiry.py::test_cache_does_not_bypass_expiryminted a key that expired in 600 ms, asserted it was still valid, then slept 0.8 s. Under parallel CI that window can already have elapsed before the first assertion, which is the flake recorded on the issue.This drives
storage.datetime.nowinstead of wall-clock sleep. The hash cache is still warmed on the first call and the second call still re-checksexpires_at.Changes
time.sleepwith a frozen clock around the twovalidate_api_keycallsTest plan
python -m pytest tests/test_api_key_expiry.py -q --tb=short(15 passed)