carlos / platform Public

edge tests: the startup gate test holds its HTTP port (deadAddr)

TestStartupGateFailsWhenHandlerSetupFails reserved a port and closed
it, then required that nothing answer there before handler setup; on
CI another test process's server took the port and answered 404. The
port is now held with deadAddr for the whole test. Setup fails before
the edge listens, so it never needs the port; an edge that bound early
would get address in use, and the test now says so plainly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev d1a9f73332d5e13b83d080dfc50fe1d33556c6e2 parent a26d434
1 file changed, +9 −7
  • internal/edge/startup_test.go +9 −7

CI passed — run details

diff --git a/internal/edge/startup_test.go b/internal/edge/startup_test.go
index 81fb78612..3a02c25f5 100644
--- a/internal/edge/startup_test.go
+++ b/internal/edge/startup_test.go
@@ -5,7 +5,6 @@ import (
"bytes"
"context"
"io"
- "net"
"net/http"
"os"
"os/exec"
@@ -23,12 +22,12 @@ func TestStartupGateFailsWhenHandlerSetupFails(t *testing.T) {
})
os.Exit(0)
}
- listener, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- t.Fatal(err)
- }
- addr := listener.Addr().String()
- listener.Close()
+ // The port stays held, never listening, for the whole test: a port that
+ // was only reserved and closed went to another test process's server,
+ // whose 404 then read as this edge serving before setup. Setup fails
+ // before this edge listens, so it never needs the port; one that bound
+ // early would fail to, and the stderr check below says so.
+ addr := deadAddr(t)
exe, err := os.Executable()
if err != nil {
t.Fatal(err)
@@ -79,6 +78,9 @@ func TestStartupGateFailsWhenHandlerSetupFails(t *testing.T) {
if err := cmd.Wait(); err == nil {
t.Fatal("invalid tunnel configuration did not fail setup")
}
+ if strings.Contains(stderr.String(), "address already in use") {
+ t.Fatalf("the edge bound its HTTP address before handler setup: %s", stderr.String())
+ }
if !strings.Contains(stderr.String(), "edge: tunnels:") {
t.Fatalf("did not reach handler setup failure: %s", stderr.String())
}