fix(test): store tests take an OS-assigned free port, not a PID-derived one
CI / Lint / Test / Vet (push) Successful in 36s
CI / Build & Import (push) Successful in 11s
CI / Deploy via GitOps (push) Skipped

PID%1000 collided with a concurrent job on the shared CI host (run on
e946709: process already listening on port 54000). freePort asks the OS;
Start is retried up to 3 times if the port is taken in between.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZkhi49hfeSqBp5aZJNXsM
This commit is contained in:
2026-10-10 10:56:24 +02:00
co-authored by Claude Sonnet 5.5
parent e946709e82
commit c4233e3e05
2 changed files with 64 additions and 18 deletions
+19
View File
@@ -0,0 +1,19 @@
package store_test
import (
"fmt"
"os"
"testing"
"github.com/stretchr/testify/require"
)
// TestMain's Postgres already holds a port. A second instance started in the
// same process must still come up, i.e. the port is not derived from something
// two starters share (the PID). Observes: startTestPostgres succeeds while
// another instance from this process is listening.
func TestStartTestPostgres_SecondInstanceStartsWhileFirstHoldsItsPort(t *testing.T) {
pg, _, rt, err := startTestPostgres(fmt.Sprintf("tapir-epg-store-second-%d", os.Getpid()))
require.NoError(t, err)
t.Cleanup(func() { _ = pg.Stop(); _ = os.RemoveAll(rt) })
}