Repository navigation
fix(test): bring up the test database from the repo, not the environment - #674
Conversation
The integration lane has been unavailable to autonomous runs for three days, and each investigation found a different cause: a setup script that exited non-zero and killed the session at zero turns; a healthy cluster misdiagnosed as absent because psql as root answers FATAL: role "root" does not exist, an auth error indistinguishable from a refused server; and finally a container holding the data directory and a stale socket with no server process, because the environment's setup script is cached between containers and had not run. That last one is the reason this moves into the repo. An environment setup script cannot be relied on to reflect its own latest edit, whereas a script in git runs at whatever version the session checked out. scripts/ensure-test-db.sh is idempotent and best-effort. It exits immediately when 5432 already answers, so a developer's own PostgreSQL is untouched and macOS is unaffected; the bring-up path is guarded to a root Linux sandbox. It clears a stale socket whose lock names a dead PID, which a warm container leaves behind and which makes a fresh start look like a live server. It also creates a root superuser role, removing the auth error that caused the second misdiagnosis. Wired into worktreeSetup and the top of the lean gate. The cost when the database is already up is one pg_isready. Co-Authored-By: Claude Opus 5 <[email protected]>
|
🚅 Deployed to the SahajCloud-pr-674 environment in sahajcloud
1 service not affected by this PR
|
|
Line 68 runs unconditionally, before the install -d -o postgres -g postgres /var/run/postgresql "$(dirname "$PGDATA")" "$PGDATA"
I hit this on today's loop container and the fix was MeasurementsThe permission flip, isolated from Postgres entirely: The refusal, from Recovery, with no other change: Why the script's own guards do not catch it. The stale-socket branch at line 74 keys on a socket file existing; here the socket was already gone, so it did not fire and nothing else re-checks the mode. Scope of the report. I have not pushed anything — this is your branch. The rest of the PR did what it says on this container: the 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
scripts/ensure-test-db.shbrings up the integration lane's PostgreSQL from the repo, not the Claude routine environmentworktreeSetupand the top of the lean gate; idempotent and best-effort, so it is a no-op locally and can never fail a sessionWhy the repo and not the environment
The integration lane has been unavailable to autonomous runs for three days, and each investigation found a different cause:
psqlasrootanswersFATAL: role "root" does not exist— an auth error indistinguishable from a refused server, misread as "no PostgreSQL"The third is why this moves into git: an environment setup script cannot be relied on to reflect its own latest edit. A script in the repo runs at whatever version the session checked out.
Behaviour
rootsuperuser role, removing the auth error behind misdiagnosis Ticket #2: Narrator Collection Implementation #2Test results
bash -nclean on both changed scriptsNotes for reviewer
docs/rules/testing-reqs.mdrecords all three misdiagnoses, because the lesson generalises: when the lane is unavailable, name the layer that refused — process, socket, auth, or database — rather than reasoning about why. Each of the three looked like "no database" and only one was.