Commit 8eea89a307
Verified · cmc ci/build: success ci/test: success ci/vuln: success
Layout: unified · split
e2e/ssh_test.go +6 −13
| @@ -10,7 +10,6 @@ import ( | ||
| 10 | 10 | "path/filepath" |
| 11 | 11 | "strings" |
| 12 | 12 | "testing" |
| 13 | "time" | |
| 14 | 13 | ) |
| 15 | 14 | |
| 16 | 15 | type instance struct { |
| @@ -113,19 +112,13 @@ port = %d | ||
| 113 | 112 | inst.proc.Wait() |
| 114 | 113 | }) |
| 115 | 114 | |
| 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) | |
| 128 | 120 | } |
| 121 | return inst | |
| 129 | 122 | } |
| 130 | 123 | |
| 131 | 124 | // admin runs a gitbayd admin command against the instance's database. |