Keep the reload-hold test upstream port reserved
Simulate temporary dial refusal through the existing test seam instead of closing an ephemeral listener and rebinding later. Preserve the reload and response assertions. Verified with 20 targeted runs and three race-detector runs.
1 file changed,
+18
−3
internal/edge/localhold_probed_test.go+18 −3
CI passed — run details
Intent
Human
Why do you keep stopping?
Human
Also, why here? https://github.com/carlosframework/platform-infrastructure/pull/51 Shouldn't it be on carlos/platform ?
diff --git a/internal/edge/localhold_probed_test.go b/internal/edge/localhold_probed_test.go| index 20feb2257..190f252a8 100644 |
| --- a/internal/edge/localhold_probed_test.go |
| +++ b/internal/edge/localhold_probed_test.go |
| @@ -381,10 +381,25 @@ func TestProbedDeadlineMidPassDoesNotEject(t *testing.T) { |
| } |
| func TestProbedHoldSurvivesReload(t *testing.T) { |
| - a := deadAddr(t) |
| var hits atomic.Int64 |
| - e, srv := probedEdge(t, []string{a}, fastHealth(), probedHold()) |
| - listenLater(t, a, 200*time.Millisecond, countingHandler(&hits)) |
| + // The upstream stays bound for the whole test: releasing a port and |
| + // rebinding it later lets another process take it in between. The dialer |
| + // refuses until up flips, which stands in for the upstream not listening. |
| + upstream := httptest.NewServer(countingHandler(&hits)) |
| + defer upstream.Close() |
| + a := upstream.Listener.Addr().String() |
| + var up atomic.Bool |
| + var plain net.Dialer |
| + hold := probedHold() |
| + hold.dialer = func(ctx context.Context, network, addr string) (net.Conn, error) { |
| + if !up.Load() { |
| + return nil, refusedErr() |
| + } |
| + return plain.DialContext(ctx, network, addr) |
| + } |
| + e, srv := probedEdge(t, []string{a}, fastHealth(), hold) |
| + avail := time.AfterFunc(200*time.Millisecond, func() { up.Store(true) }) |
| + defer avail.Stop() |
| reloaded := make(chan error, 1) |
| go func() { |
| time.Sleep(100 * time.Millisecond) |