Skip to content

refactor: use vi for waiting - #1676

Open
ferhatelmas wants to merge 1 commit into
masterfrom
ferhat/vi-wait
Open

ferhatelmas wants to merge 1 commit into
masterfrom
ferhat/vi-wait

Conversation

@ferhatelmas

Copy link
Copy Markdown
Member

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.

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
@ferhatelmas
ferhatelmas requested a review from a team as a code owner November 6, 2026 18:20
Copilot AI balanced review requested due to automatic review settings November 6, 2026 18:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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, and expect.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

@blacksmith-sh

blacksmith-sh Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
acceptance/specs/iceberg.test.ts/Iceberg catalog contract >
covers analytics buckets, catalog config, namespaces, and table lifecycle
View Logs
acceptance/specs/iceberg.test.ts/Iceberg catalog contract >
covers analytics buckets, catalog config, namespaces, and table lifecycle
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 42269791308

Coverage decreased (-0.001%) to 87.541%

Details

  • Coverage decreased (-0.001%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15984
Covered Lines: 14432
Line Coverage: 90.29%
Relevant Branches: 10165
Covered Branches: 8459
Branch Coverage: 83.22%
Branches in Coverage %: Yes
Coverage Strength: 1298.11 hits per line

💛 - Coveralls

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sets IfNoneMatch, so renewalSent only matches the renewal PUT (which uses IfMatch). The zombie test sets renewalPutSettled in a finally, so it also covers the case where the PUT fails with PreconditionFailed.
  • object-versioning: waitForBlockedBackend checks 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants