Repository navigation
test(qwp): fix port collision flake in walk tracker test - #103
Conversation
testWalk_TransportFailureContinuesWalk failed in CI with "duplicate addr entry: localhost:46809" thrown by ConfigView.parseEntry(). The test called TestPorts.findUnusedPort() to pick a refused port. That helper binds port 0, closes the probe socket and returns the number. The test then created a TestWebSocketServer, whose constructor binds its own port 0. Nothing held the probe port in between, so the kernel could hand the same port to the server. Both addr entries then pointed at the same endpoint, and QwpQueryClient.fromConfig() rejected the config before the walk ever ran. The test now creates the server first and probes for the dead port while the server's listener holds its port. The kernel never assigns a port that a live listener owns, so the two ports always differ. The remaining exposure - another process taking the dead port before the client connects - matches every other pre-selected-port test in the suite.
|
Reviewing PR #103 at level 3, the full review: surface map, discovery fan-out and independent falsification. PR #103 — test(qwp): fix port collision flake in walk tracker testVerdict: approve. The root cause is correct and the fix closes it. I found nothing to report at any severity. Reviewed head Title and description: the title follows Conventional Commits and the QWP label fits. The description sets out failure, root cause, change, tradeoff and test plan, and each claim checked out. Commit Submodule provenance: no submodule pointer moved (zstd is unchanged), and the diff contains no binaries. Is the fix real?
Runtime evidenceI ran these on Temurin 8u504, Linux 6.6 aarch64 container.
CriticalNone. ModerateNone. MinorNone. Coverage mapThe test gate passes with 0 admitted coverage gaps. No production behaviour changed, and the test still drives the same refused-first-endpoint path with the same assertions. The change can be tested here alone, so no OSS or Enterprise tandem PR is needed (searches by branch name found none). Summary
|
Test-only change. It fixes an intermittent failure of
QwpQueryClientWalkTrackerTest.testWalk_TransportFailureContinuesWalk.Failure
The test failed on questdb/questdb#7680 CI, job "SelfHosted Other tests (B) on linux-x64-zfs" (build 274943):
Root cause
The test builds
addr=localhost:<portDead>,localhost:<portOk>:TestPorts.findUnusedPort()suppliesportDead: it binds port 0, closes the probe socket, and returns the number. Nothing holds the port afterwards.new TestWebSocketServer(NOOP_HANDLER)then binds its own port 0 forportOk, and the kernel may hand it the port the probe just released.In the failing run both values came out as 46809.
ConfigView.parseEntry()correctly rejects the duplicate(host, port)pair, sofromConfig()threw before the client attempted any connection. The walk-tracker logic the test targets never ran, and the product code behaved as specified.The
TestPorts.findUnusedPorts(int)javadoc already describes the same race for two back-to-backfindUnusedPort()calls. This test pairs one probe with a server's ownbind(0), which that helper does not cover.Change
The test now creates the server first and probes for
portDeadwhile the server's listener holdsportOk.TestWebSocketServerbinds its listener in the constructor and keeps it untilclose(), and the kernel never assigns abind(0)port that a live socket on the same address holds, so the two ports cannot collide.Tradeoff: the test keeps the suite's existing bind-close-reuse exposure, where another process could bind
portDeadbetween the probe and the client's connect attempt. Every other pre-selected-port test in the suite accepts the same exposure. The change touches no production code and no shared test helper.Test plan
mvn -pl core test -Dtest=QwpQueryClientWalkTrackerTest: 12/12 green on JDK 25, both on0b9b5766(the commit questdb master pins) and on this branch (mainplus the fix).