test: two more tests derive their port from the PID (55000 + pid%1000) and can collide like the store test did #65

Open
opened 2026-10-10 09:02:06 +00:00 by mathias · 0 comments
Owner

Follow-up to the store-test fix (c4233e3, v0.33.2). That fix replaced 54000 + os.Getpid()%1000 in internal/adapters/store/store_test.go with an OS-assigned port after run 9563 failed with embedded-postgres start: process already listening on port 54000 (a concurrent job on the shared runner held it).

Two more places use the same PID-derived scheme and can fail the same way:

  • internal/web/handlers_test.go:34
  • cmd/tapir/e2e_upload_test.go:53 (55000 + pid%1000)

Fix the same way: ask the OS (net.Listen(":0"), read the port, close) and retry Start a couple of times with a fresh port; reuse the freePort() / startTestPostgres helper from the store package if it can be shared without an import cycle, else keep a small copy. Test first: pre-bind the port the old scheme would pick and assert the suite still starts.

risk/low.


Created via git-mcp on behalf of @mathias

Follow-up to the store-test fix (c4233e3, v0.33.2). That fix replaced `54000 + os.Getpid()%1000` in `internal/adapters/store/store_test.go` with an OS-assigned port after run 9563 failed with `embedded-postgres start: process already listening on port 54000` (a concurrent job on the shared runner held it). Two more places use the same PID-derived scheme and can fail the same way: - `internal/web/handlers_test.go:34` - `cmd/tapir/e2e_upload_test.go:53` (`55000 + pid%1000`) Fix the same way: ask the OS (`net.Listen(":0")`, read the port, close) and retry `Start` a couple of times with a fresh port; reuse the `freePort()` / `startTestPostgres` helper from the store package if it can be shared without an import cycle, else keep a small copy. Test first: pre-bind the port the old scheme would pick and assert the suite still starts. risk/low. --- _Created via git-mcp on behalf of @mathias_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mathias/tapir#65