Author SHA1 Message Date
sneak 230248d058 Tests no longer connect to test servers they closed (closes #257)
check / check (push) Successful in 5m12s
Three tests closed a test server and then connected to its port. Another
test process could take that port in between and receive the connection.

- TestUnreachableRouteWatchLetsTheRequestThroughAndSaysWhy and
  TestUnreachableRoutewatchFailsTheQueryAndTheLogOmitsTheClient, formerly
  TestRefusedConnection..., point routewatch at 224.0.0.1, a multicast
  address to which TCP cannot connect.
- TestStalledRemoteLogEndpointHoldsUpNoRequest keeps its endpoint open
  and closes each connection it takes, instead of closing the endpoint.

No change to non-test code.

Model: opus-5-5
2026-11-09 22:19:41 +00:00
3 changed files with 24 additions and 12 deletions

No files matched your search

@@ -153,14 +153,10 @@ func TestUnsetRouteWatchChangesNothing(t *testing.T) {
func TestUnreachableRouteWatchLetsTheRequestThroughAndSaysWhy(t *testing.T) { func TestUnreachableRouteWatchLetsTheRequestThroughAndSaysWhy(t *testing.T) {
t.Parallel() t.Parallel()
// A stand-in that is closed at once, so that the port refuses connections. // Another test can take a closed server's port at once, so routewatch's
dead := httptest.NewServer(http.NotFoundHandler()) // address here is a multicast address, to which TCP cannot connect.
url := dead.URL
dead.Close()
s, _, _ := startWithClock(t, "", map[string]string{ s, _, _ := startWithClock(t, "", map[string]string{
lookupSource: off, routeWatchURL: url, lookupSource: off, routeWatchURL: "http://224.0.0.1",
}) })
wantTagsMissing(t, s.get(fromDE, http.StatusOK, requestlog.ActionForward), wantTagsMissing(t, s.get(fromDE, http.StatusOK, requestlog.ActionForward),
+7 -2
View File
@@ -239,12 +239,17 @@ func TestAnswerRoutewatchCannotBeTakenFromFails(t *testing.T) {
} }
} }
func TestRefusedConnectionFailsTheQueryAndTheLogOmitsTheClient(t *testing.T) { func TestUnreachableRoutewatchFailsTheQueryAndTheLogOmitsTheClient(t *testing.T) {
t.Parallel() t.Parallel()
f := newFixture(t, answering(routedAnswer)) f := newFixture(t, answering(routedAnswer))
f.server.Close() // Another test can take a closed server's port at once, so routewatch's
// address here is a multicast address, to which TCP cannot connect.
f.client = routewatch.New(routewatch.Params{
URL: "http://224.0.0.1/", Now: f.clk.Now,
ProcessLog: slog.New(slog.NewTextHandler(f.log, nil)),
})
f.route() f.route()
f.waitFor(routewatch.RequestFailed) f.waitFor(routewatch.RequestFailed)
+14 -3
View File
@@ -975,9 +975,20 @@ func TestStalledRemoteLogEndpointHoldsUpNoRequest(t *testing.T) {
t.Errorf("no line dropped in the metrics:\n%s", metrics) t.Errorf("no line dropped in the metrics:\n%s", metrics)
} }
// Closed, the endpoint refuses the connection made to send the // From here the endpoint closes each connection it takes, so the
// lines still waiting at the stop, which then does not wait. // one made to send the lines still waiting at the stop fails at
_ = endpoint.Close() // once. Closing the endpoint instead would free its port for
// another test to take.
go func() {
for {
conn, err := endpoint.Accept()
if err != nil {
return
}
_ = conn.Close()
}
}()
}) })
out.line(t, "type", "request") out.line(t, "type", "request")