freePort in e2e/ssh_test.go closes its listener before returning, so consecutive calls can be assigned the same ephemeral port. Every instance asks for three in a row:
port: freePort(t),
httpPort: freePort(t),
gitPort: freePort(t),
When two collide, gitbayd binds the first and fails the second, and the test that started it times out waiting.
Caught in build 157:
INFO ssh listening addr=[::]:41233
INFO git-daemon listening addr=[::]:33767
INFO http listening addr=127.0.0.1:33767 tls=off
gitbayd: listen tcp 127.0.0.1:33767: bind: address already in use
--- FAIL: TestCLI (11.06s)
ssh_test.go:50: gitbayd did not start listening
The failing test is whichever one draws the collision, so it moves around and always looks unrelated to the change under test. This is the genuine intermittent e2e failure — distinct from #67, where a dropped log stream failed builds whose tests had passed. The two produce different evidence: #67 leaves a truncated log with no FAIL line, this leaves a complete log naming a test.
The fix is to hold every listener open until all the ports are chosen, so the kernel cannot issue one twice, then close them together. TestACMEServe and the restore half of the backup test allocate in pairs the same way and need the same treatment.
This is a narrowing, not an elimination: another process can still take a port between the close and gitbayd's bind. Distinctness within one instance is the part that is ours to fix, and it is the part that is failing.
closed by commit 62742f1870 by cmc: e2e: reserve every port before releasing any of them
2026-09-01 07:08 UTC