Repository navigation
refactor: use vi for waiting - #1676
ferhatelmas wants to merge 1 commit into
Conversation
Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the test-suite polling refactor.
No open issues 🎉
What changed in this PR
This PR standardizes asynchronous waits across the test suite using Vitest’s polling APIs, replacing custom polling helpers and several fixed delays without changing production code.
Changes:
- Replace custom polling with
vi.waitFor,vi.waitUntil, andexpect.poll. - Wait for observable S3 renewal and database lock states instead of fixed delays.
- Remove the shared polling utility and the fixed delay before RLS policy cleanup.
| File | Description |
|---|---|
src/test/utils/promise.ts |
Delete the custom waitForEventually helper. |
src/test/tenant-jwks.test.ts |
Use Vitest polling for tenant key configuration changes. |
src/test/s3-locker.test.ts |
Observe renewal requests and completion instead of sleeping. |
src/test/rls.test.ts |
Remove the delay before policy cleanup. |
src/test/object-versioning-writes.test.ts |
Poll database lock activity to coordinate concurrent operations. |
src/test/lifecycle-tenants-migration.test.ts |
Replace manual database polling with expect.poll. |
src/test/lifecycle-migration-upgrade.test.ts |
Use expect.poll to wait for database rows. |
src/storage/renderer/image.test.ts |
Replace the local condition-wait helper with vi.waitFor. |
src/internal/streams/hash-stream.test.ts |
Use Vitest polling to verify spill-file cleanup. |
Review effort: Balanced
|
Found 2 test failures on Blacksmith runners: Failures
|
Coverage Report for CI Build 42269791308Coverage decreased (-0.001%) to 87.541%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. Every changed path falls under the repository-wide CODEOWNERS entry, so a code owner should still take a look.
What was reviewed:
- s3-locker: the spies are installed before
lock(), and the acquisition PUT always setsIfNoneMatch, sorenewalSentonly matches the renewal PUT (which usesIfMatch). The zombie test setsrenewalPutSettledin afinally, so it also covers the case where the PUT fails with PreconditionFailed. - object-versioning:
waitForBlockedBackendchecks for any backend in the database that is waiting on a lock, not the specific query. At worst it returns early, which still guarantees at least as much as the 100ms/300ms sleeps it replaces. - rls: every operation is awaited before the outer
finally, so removing the 2s wait before the policy drop doesn't leave any request running.
Extended reasoning...
This PR only changes test files. It replaces custom polling helpers and fixed sleeps with Vitest's expect.poll, vi.waitFor and vi.waitUntil, and deletes src/test/utils/promise.ts. It doesn't touch production code or any security-sensitive area. I didn't approve because .github/CODEOWNERS assigns every path to the storage team. Some of the new wait conditions also change timing in the concurrency tests, which a code owner is better placed to judge.
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png)
What kind of change does this PR introduce?
refactor
What is the current behavior?
We had some custom functions for waiting state changes.
What is the new behavior?
We moved to vitest 5 and it's provided by its api, use that instead.