Tests that connect to a closed test server receive another test's server #257

Closed
opened 2026-11-09 22:33:08 +01:00 by clawbot · 2 comments
Collaborator

Tests that close a test server and then connect to its port fail other packages' tests when another test server takes that port in between. This is the cause in #158, in other tests.

Seen. make check on the branch of #253 at cde2f14, which changes only Core Rule Set tests, failed once in internal/rproxy:

  • TestQuestionNamesTheClientAsTheForwardedAddressesSay/the_peer,_with_no_header: rproxy_test.go:190: GET /api/v1/ip/203.0.113.9 is no report: EOF.
  • rproxy's stand-in for discriminator received a routewatch query. 203.0.113.9 is the client address of discriminator's tests (internal/discriminator/proxy_test.go).
  • TestUnreachableRouteWatchLetsTheRequestThroughAndSaysWhy in internal/discriminator/routewatchtags_test.go closes its stand-in and then sends routewatch queries to that port. rproxy's stand-in, in another test process, had taken the port.
  • The -v rerun in the same build passed.

TestRefusedConnectionFailsTheQueryAndTheLogOmitsTheClient in internal/routewatch/routewatch_test.go does the same, closing f.server before querying it.

Definition of done.

  • Both tests use an address that refuses connections without depending on a closed port staying free, as #158 did for its test.
  • No other test in the repo connects to a test server it has closed.
  • One reviewed PR into next, its title ending with (closes #N), N being this issue.

Model: opus-5-5

Tests that close a test server and then connect to its port fail other packages' tests when another test server takes that port in between. This is the cause in https://git.eeqj.de/sneak/smallwebwaf/issues/158, in other tests. **Seen.** `make check` on the branch of https://git.eeqj.de/sneak/smallwebwaf/pulls/253 at `cde2f14`, which changes only Core Rule Set tests, failed once in `internal/rproxy`: - `TestQuestionNamesTheClientAsTheForwardedAddressesSay/the_peer,_with_no_header`: `rproxy_test.go:190: GET /api/v1/ip/203.0.113.9 is no report: EOF`. - rproxy's stand-in for discriminator received a routewatch query. `203.0.113.9` is the client address of discriminator's tests (`internal/discriminator/proxy_test.go`). - `TestUnreachableRouteWatchLetsTheRequestThroughAndSaysWhy` in `internal/discriminator/routewatchtags_test.go` closes its stand-in and then sends routewatch queries to that port. rproxy's stand-in, in another test process, had taken the port. - The `-v` rerun in the same build passed. `TestRefusedConnectionFailsTheQueryAndTheLogOmitsTheClient` in `internal/routewatch/routewatch_test.go` does the same, closing `f.server` before querying it. **Definition of done.** - Both tests use an address that refuses connections without depending on a closed port staying free, as https://git.eeqj.de/sneak/smallwebwaf/issues/158 did for its test. - No other test in the repo connects to a test server it has closed. - One reviewed PR into `next`, its title ending with (closes #N), N being this issue. Model: opus-5-5
Author
Collaborator

Plan. Test files only, in the packages that hold the two tests: internal/discriminator/routewatchtags_test.go and internal/routewatch/routewatch_test.go.

  • Point each at an address nothing can connect to, as fdabf49 did for #158 in internal/smallwebwaf/healthcheck_test.go: a multicast address such as http://224.0.0.1, to which TCP cannot connect, with a one-line comment saying why. Keep each test's assertions as they are, unless the error text differs; then match the new text as narrowly as the old.
  • Search every _test.go file for a test server that is closed and then connected to (Close() on an httptest.Server followed by a request to its URL), and fix each the same way. Name each in the PR body.
  • No change to non-test code.

make fmt, then flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check; a flock timeout also exits 1, so read the output. Label the PR needs-review.

Model: opus-5-5

**Plan.** Test files only, in the packages that hold the two tests: `internal/discriminator/routewatchtags_test.go` and `internal/routewatch/routewatch_test.go`. - Point each at an address nothing can connect to, as `fdabf49` did for https://git.eeqj.de/sneak/smallwebwaf/issues/158 in `internal/smallwebwaf/healthcheck_test.go`: a multicast address such as `http://224.0.0.1`, to which TCP cannot connect, with a one-line comment saying why. Keep each test's assertions as they are, unless the error text differs; then match the new text as narrowly as the old. - Search every `_test.go` file for a test server that is closed and then connected to (`Close()` on an `httptest.Server` followed by a request to its URL), and fix each the same way. Name each in the PR body. - No change to non-test code. `make fmt`, then `flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check`; a `flock` timeout also exits 1, so read the output. Label the PR `needs-review`. Model: opus-5-5
clawbot self-assigned this 2026-11-09 23:10:00 +01:00
Author
Collaborator

Built in #260. Both tests now use http://224.0.0.1. The search found one more test with the same fault: TestStalledRemoteLogEndpointHoldsUpNoRequest in internal/sww/sww_test.go closed its syslog endpoint before connecting to it again. It now keeps the endpoint open and closes each connection it takes.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/smallwebwaf/pulls/260. Both tests now use `http://224.0.0.1`. The search found one more test with the same fault: `TestStalledRemoteLogEndpointHoldsUpNoRequest` in `internal/sww/sww_test.go` closed its syslog endpoint before connecting to it again. It now keeps the endpoint open and closes each connection it takes. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/smallwebwaf#257