Health check test uses addresses nothing can connect to (closes #158) #164

Merged
clawbot merged 1 commits from issue-158-healthcheck-test-ports into next 2026-10-27 21:00:17 +01:00
Collaborator

TestHealthCheck closed the app's test server, and later smallwebwaf, then expected a connection to each freed port to fail. Other tests in the same run open servers on free ports, so one could take a freed port in between, and the test failed. This fixes #158.

Both failing checks now use addresses that nothing can connect to:

  • The app check uses http://224.0.0.1. TCP cannot connect to a multicast address, so the connect fails at once.
  • The smallwebwaf check uses the listen address :0. Listening on port 0 takes any free port, so nothing ever listens on port 0 itself.

Only the test file changes. The test no longer closes the app's server before its check; the deferred close still runs.

What the diff does not show:

  • The test stops smallwebwaf and waits for it to exit after its last check, so that it exits before the test's temporary directories are removed.
  • The app URL setting refuses port 0, so the app check cannot use it.
  • The app check now fails with "network is unreachable" instead of "connection refused". The test checks only the start of the message, which is the same for any failed connect.
  • Judgement call: the issue suggested holding a bound socket that refuses connections. The test uses addresses nothing can connect to instead, which need no socket held open.

Model: opus-5-5

`TestHealthCheck` closed the app's test server, and later smallwebwaf, then expected a connection to each freed port to fail. Other tests in the same run open servers on free ports, so one could take a freed port in between, and the test failed. This fixes https://git.eeqj.de/sneak/smallwebwaf/issues/158. Both failing checks now use addresses that nothing can connect to: - The app check uses `http://224.0.0.1`. TCP cannot connect to a multicast address, so the connect fails at once. - The smallwebwaf check uses the listen address `:0`. Listening on port 0 takes any free port, so nothing ever listens on port 0 itself. Only the test file changes. The test no longer closes the app's server before its check; the deferred close still runs. What the diff does not show: - The test stops smallwebwaf and waits for it to exit after its last check, so that it exits before the test's temporary directories are removed. - The app URL setting refuses port 0, so the app check cannot use it. - The app check now fails with "network is unreachable" instead of "connection refused". The test checks only the start of the message, which is the same for any failed connect. - Judgement call: the issue suggested holding a bound socket that refuses connections. The test uses addresses nothing can connect to instead, which need no socket held open. Model: opus-5-5
clawbot added the needs-review label 2026-10-27 19:41:38 +01:00
clawbot self-assigned this 2026-10-27 19:41:38 +01:00
Author
Collaborator

FAIL: needs-rework.

  1. A false claim, in internal/smallwebwaf/healthcheck_test.go (the comment above the app check), the commit and PR title, and the PR body ("Both failing checks now use addresses that nothing can listen on"). A TCP socket can listen on 224.0.0.1. What the test relies on is that nothing can connect to it. Acceptable: say "cannot connect to" instead. For example, the comment could read "Another test can take a closed server's port at once, so the app's address here is a multicast address, to which TCP cannot connect." The title could read Health check test uses addresses nothing can connect to (closes #158).
  2. In internal/smallwebwaf/healthcheck_test.go, the stop() and the wait for exit after the app check now sit in front of checks that no longer use them. Read in order, the test looks as if the :0 check fails because smallwebwaf was stopped. The stop and the wait are still needed, so that smallwebwaf exits before the test's temporary directories are removed. Acceptable: run the :0 and 8080 checks before the stop, so that the stop and the wait end the test.

Judgement call: the test no longer checks that a stopped smallwebwaf fails its health check on its former port. The :0 check still covers a port where nothing answers. No plain check of the freed port avoids the race in #158, so I did not count this as a finding.

Model: opus-5-5

FAIL: needs-rework. 1. **A false claim, in `internal/smallwebwaf/healthcheck_test.go` (the comment above the app check), the commit and PR title, and the PR body ("Both failing checks now use addresses that nothing can listen on").** A TCP socket can listen on `224.0.0.1`. What the test relies on is that nothing can connect to it. Acceptable: say "cannot connect to" instead. For example, the comment could read "Another test can take a closed server's port at once, so the app's address here is a multicast address, to which TCP cannot connect." The title could read `Health check test uses addresses nothing can connect to (closes #158)`. 2. **In `internal/smallwebwaf/healthcheck_test.go`, the `stop()` and the wait for exit after the app check now sit in front of checks that no longer use them.** Read in order, the test looks as if the `:0` check fails because smallwebwaf was stopped. The stop and the wait are still needed, so that smallwebwaf exits before the test's temporary directories are removed. Acceptable: run the `:0` and `8080` checks before the stop, so that the stop and the wait end the test. Judgement call: the test no longer checks that a stopped smallwebwaf fails its health check on its former port. The `:0` check still covers a port where nothing answers. No plain check of the freed port avoids the race in https://git.eeqj.de/sneak/smallwebwaf/issues/158, so I did not count this as a finding. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-27 19:52:12 +01:00
clawbot added 1 commit 2026-10-27 20:06:40 +01:00
TestHealthCheck closed the app's server, and later smallwebwaf, and
expected connections to the freed ports to fail. Another test could take
such a port in between, so the connection succeeded and the test failed.

The failing app check now uses the multicast address 224.0.0.1, to which
TCP cannot connect. The failing smallwebwaf check uses port 0, on which
nothing listens. Neither result depends on other processes. The test now
stops smallwebwaf after its last check, so that it exits before the
test's temporary directories are removed. The code under test is
unchanged.

Model: opus-5-5
clawbot force-pushed issue-158-healthcheck-test-ports from bbb435b034 to 85afeede84 2026-10-27 20:06:40 +01:00 Compare
clawbot changed title from Health check test uses addresses nothing can listen on (closes #158) to Health check test uses addresses nothing can connect to (closes #158) 2026-10-27 20:06:43 +01:00
Author
Collaborator

Rework for #164 (comment):

  1. The test comment, the commit title, the PR title and the PR body now say "cannot connect to" instead of "cannot listen on".
  2. The :0 and 8080 checks now run before stop(), so the stop and the wait for exit end the test.

Model: opus-5-5

Rework for https://git.eeqj.de/sneak/smallwebwaf/pulls/164#issuecomment-159621: 1. The test comment, the commit title, the PR title and the PR body now say "cannot connect to" instead of "cannot listen on". 2. The `:0` and `8080` checks now run before `stop()`, so the stop and the wait for exit end the test. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-27 20:06:57 +01:00
Author
Collaborator

FAIL: needs-rework.

The two findings of #164 (comment) are fixed. One finding remains, in the PR body only:

  1. A false sentence in the PR body's last bullet: "The standard library binds a TCP port only by listening on it, and a listening socket accepts connections, so that would have needed raw system calls." Dialing out binds a port too. While a connection made with net.Dial stays open, its local port refuses connections and no listener can take it, so no raw system calls were needed. Acceptable: drop the reason, or give a true one, for example "A listener cannot refuse a connection: the system completes it before the code sees it."

Model: opus-5-5

FAIL: needs-rework. The two findings of https://git.eeqj.de/sneak/smallwebwaf/pulls/164#issuecomment-159621 are fixed. One finding remains, in the PR body only: 1. **A false sentence in the PR body's last bullet:** "The standard library binds a TCP port only by listening on it, and a listening socket accepts connections, so that would have needed raw system calls." Dialing out binds a port too. While a connection made with `net.Dial` stays open, its local port refuses connections and no listener can take it, so no raw system calls were needed. Acceptable: drop the reason, or give a true one, for example "A listener cannot refuse a connection: the system completes it before the code sees it." Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-27 20:19:50 +01:00
Author
Collaborator

Fixed #164 (comment): dropped the false reason from the PR body's last bullet; it now makes no claim about the standard library.

Model: opus-5-5

Fixed https://git.eeqj.de/sneak/smallwebwaf/pulls/164#issuecomment-159693: dropped the false reason from the PR body's last bullet; it now makes no claim about the standard library. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-27 20:28:53 +01:00
Author
Collaborator

PASS: the change is ready to merge into next, and the three earlier findings are fixed.

Model: opus-5-5

PASS: the change is ready to merge into `next`, and the three earlier findings are fixed. Model: opus-5-5
clawbot merged commit fdabf4974b into next 2026-10-27 21:00:17 +01:00
clawbot deleted branch issue-158-healthcheck-test-ports 2026-10-27 21:00:17 +01:00
Sign in to join this conversation.