Retry PROXY e2e reads while the tunnel handshake completes
The first connection through the tunnel can exceed the read deadline on a slow CI runner. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58d1cfe9a3
commit
7db686eeb0
1 file changed
+4
-4
@@ -91,7 +91,10 @@ func proxyBackend(t *testing.T, seen chan<- string) int {
|
||||
func askFrom(t *testing.T, from, addr, send string) string {
|
||||
t.Helper()
|
||||
var last error
|
||||
for i := 0; i < 50; i++ {
|
||||
// The first connection through the tunnel can wait for the WireGuard handshake, which is
|
||||
// slow on a busy CI runner, so a read timeout is retried until the overall deadline.
|
||||
deadline := time.Now().Add(30 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
d := net.Dialer{LocalAddr: &net.TCPAddr{IP: net.ParseIP(from)}, Timeout: time.Second}
|
||||
c, err := d.Dial("tcp", addr)
|
||||
if err == nil {
|
||||
@@ -102,9 +105,6 @@ func askFrom(t *testing.T, from, addr, send string) string {
|
||||
if rerr == nil {
|
||||
return strings.TrimSpace(line)
|
||||
}
|
||||
if ne, ok := rerr.(net.Error); ok && ne.Timeout() {
|
||||
t.Fatalf("%s accepted the connection but never answered: %v", addr, rerr) // a real hang, not a startup race
|
||||
}
|
||||
last = rerr
|
||||
} else {
|
||||
last = err
|
||||
|
||||
Reference in new issue
Block a user