e2e: an instance is ready on every listener before a test starts !183

merged merged by cmc on 2026-09-03 01:18 UTC · krz/gitbay:stack-12-harness into main

1 file changed, +6 −13

Layout: unified · split

e2e/ssh_test.go +6 −13
@@ -10,7 +10,6 @@ import (
1010 "path/filepath"
1111 "strings"
1212 "testing"
13 "time"
1413)
1514
1615type instance struct {
@@ -113,19 +112,13 @@ port = %d
113112 inst.proc.Wait()
114113 })
115114
116 // Wait for the listener.
117 deadline := time.Now().Add(10 * time.Second)
118 for {
119 conn, err := net.DialTimeout("tcp", fmt.Sprintf("127.0.0.1:%d", inst.port), 200*time.Millisecond)
120 if err == nil {
121 conn.Close()
122 return inst
123 }
124 if time.Now().After(deadline) {
125 t.Fatal("gitbayd did not start listening")
126 }
127 time.Sleep(50 * time.Millisecond)
115 // Every listener, not just SSH: the HTTP and git ones come up in their
116 // own goroutines, and a test whose first act is an HTTP request used
117 // to race them and be refused.
118 for _, port := range []int{inst.port, inst.httpPort, inst.gitPort} {
119 waitForPort(t, port)
128120 }
121 return inst
129122}
130123
131124// admin runs a gitbayd admin command against the instance's database.