Commit 01ae5cf9a0

01ae5cf9a0397d2ec7fdddf1af27d67982494e81

parent: ceafd97e30

Verified · cmc ci/build: success ci/test: success

cmc <hello@cleberg.net> · 2026-09-29 02:12 UTC

e2e: hand out ports below the ephemeral range

A test's gitbayd failed to bind a port an outgoing connection had taken (32864, inside bay1's 32768-60999). Ref #300

Layout: unified · split

e2e/ssh_test.go +9 −5
@@ -29,12 +29,16 @@ type instance struct {
2929 stderr *tailBuffer // the end of the first serve's stderr
3030}
3131
32// nextPort hands out candidate ports. Seeded randomly so two test processes
33// on one machine — `go test ./...` runs packages concurrently — start in
34// different places.
32// nextPort hands out candidate ports below 32768, where Linux and macOS
33// start the ports they give outgoing connections: a git or SMTP client in
34// another test cannot take one between the bind test and gitbayd's bind.
35// Seeded randomly so two test processes on one machine — `go test ./...`
36// runs packages concurrently — start in different places.
37const lastPort = 32000
38
3539var nextPort = func() *atomic.Int32 {
3640 var n atomic.Int32
37 n.Store(int32(20000 + rand.IntN(20000)))
41 n.Store(int32(10000 + rand.IntN(10000)))
3842 return &n
3943}()
4044
@@ -58,7 +62,7 @@ func freePorts(t *testing.T, n int) []int {
5862 ports := make([]int, 0, n)
5963 for len(ports) < n {
6064 p := int(nextPort.Add(1))
61 if p > 60000 {
65 if p > lastPort {
6266 t.Fatal("ran out of ports")
6367 }
6468 ln, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", p))