brokenUpstreamAddr returns the address of a TCP listener that accepts connections but immediately closes them, causing a transport error (not a dial error). This simulates an upstream that is reachable but broken
(t *testing.T)
| 569 | // connections but immediately closes them, causing a transport error (not |
| 570 | // a dial error). This simulates an upstream that is reachable but broken |
| 571 | func brokenUpstreamAddr(t *testing.T) string { |
| 572 | t.Helper() |
| 573 | ln, err := net.Listen("tcp", "127.0.0.1:0") |
| 574 | if err != nil { |
| 575 | t.Fatalf("failed to listen: %v", err) |
| 576 | } |
| 577 | t.Cleanup(func() { ln.Close() }) |
| 578 | go func() { |
| 579 | for { |
| 580 | conn, err := ln.Accept() |
| 581 | if err != nil { |
| 582 | return |
| 583 | } |
| 584 | conn.Close() |
| 585 | } |
| 586 | }() |
| 587 | return ln.Addr().String() |
| 588 | } |
| 589 | |
| 590 | // TestTransportErrorPlaceholder verifies that the is_transport_error |
| 591 | // placeholder is set to true during transport error evaluation in tryAgain() |