Repository navigation
Fix flaky TestIsViteReady/vite_is_running - #7837
Conversation
Poll isViteReady on a free port instead of a single 100ms dial on 5173. Co-authored-by: Isaac <no-reply@databricks.com>
✅ Integration test reportCommit: 9dbcde7
Top 6 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at 9dbcde7. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) below.
This test-only PR fixes flakiness in TestIsViteReady/vite_is_running by switching from a fixed port to an ephemeral one and replacing the single-shot check with an assert.Eventually retry loop. The ephemeral-port change is clean. The retry loop is quite generous (10 s / 50 ms ≈ 200 attempts), which could mask a regression where isViteReady almost never succeeds on a healthy listener; tightening the budget to match the production retry window would keep the flake fix while preserving the test's diagnostic value.
| // unbound ::1 before 127.0.0.1, one attempt can time out. Poll like the | ||
| // production wait loop does. | ||
| port := listener.Addr().(*net.TCPAddr).Port | ||
| assert.Eventually(t, func() bool { return isViteReady(port) }, 10*time.Second, 50*time.Millisecond) |
There was a problem hiding this comment.
[nice to have] assert.Eventually(..., 10*time.Second, 50*time.Millisecond) gives ~200 attempts, while the production loop in startViteDevServer budgets viteReadyMaxAttempts × viteReadyCheckInterval = 5 s with 50 attempts. If isViteReady regressed to succeeding only once every few seconds on a healthy local listener, this test would still pass. Consider capping at time.Duration(viteReadyMaxAttempts)*viteReadyCheckInterval (or even shorter — a handful of retries should be plenty for a loopback dial) so the test stays close to the production contract while still absorbing the dual-stack delay.
Why
TestIsViteReady/vite_is_runningflakes, mostly on Windows, and passes on retry. It made a singleisViteReady(5173)call, and that call allows onlyviteReadyCheckInterval(100ms) for the TCP dial tolocalhost. Every failure took 0.19–0.53s: the 50ms sleep plus a dial that ran out of time. On Windows, dialinglocalhostcan try::1first, where nothing listens (the listener is on 127.0.0.1). A refused loopback connection on Windows is slow, so the 127.0.0.1 attempt gets little or none of the 100ms budget. On a loaded Linux runner a single dial can also miss it.Changes
localhost:0instead of the fixed 5173, so the check can't collide with anything else on that port.isViteReadywithassert.Eventually(10s, 50ms tick), the same waystartViteDevServerretries in production, instead of one sleep and one attempt.Test-only; production code is unchanged.
Dashboard
dev_test.go:43: Error: Should be true/--- FAIL: TestIsViteReady/vite_is_running (0.22s)Tests
go test ./cmd/apps -run TestIsViteReady -count=20passes locally (Linux).AI agent (opus5.5, isaac_claude)
This pull request and its description were written by Isaac.