Repository navigation
docs: correct the test-setup instructions around Postgres - #149
Merged
Merged
Conversation
Two contributors independently reported test_smoke.py::test_login_and_self_scan failing and needing a local Postgres. They were right, and the docs told them otherwise. CONTRIBUTING.md stated the suite needs "neither a cluster nor a database". That holds for the RBAC/scoring/remediation tests but not for test_smoke.py, which drives the real startup path (create_all + tenant/admin seeding) through TestClient and therefore opens a real connection. Without Postgres it fails with OperationalError: Connection refused — expected, but reading as a broken checkout given what the page promised. The failure was previously written off as unreproducible because it does not reproduce on a machine that happens to run Postgres on 5432 — as this maintainer's does, and as CI does via its postgres service container. Pointing DATABASE_URL at a closed port reproduces the contributor reports exactly. Second trap, also now documented: `make db` publishes on 55432 while the application default is 5432. `make test` passes DATABASE_URL and works, but the command in test_smoke.py's own docstring did not set it, so following the docstring after `make db` targeted the wrong port and failed. Document which test needs a database, show the exact error so it is recognised as expected, give the correct direct-pytest invocation, and give a --ignore one-liner for running everything else with no database at all. Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
Invigil —
|
| Gate | Check | Effort | Why | Fix |
|---|---|---|---|---|
| G4 | OpenSSF Scorecard >= 7 | hours | score 6.8 < 7 | triage the Scorecard findings (branch protection, token perms, pinned deps) to reach >=7 |
30 passing · 1 failing · 4 skipped · report-only
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the "phantom Postgres failure" open finding — except it was never phantom. The contributors were right and our docs were wrong.
What was believed
Two contributors — @shariqueahmad108-ship-it (#131) and @Diyaaa-12 (#123) — independently reported
test_smoke.py::test_login_and_self_scanfailing and needing a local Postgres. This was written off as a setup problem on their machines, on the grounds that the suite passes here with no Postgres and no Docker.What is actually true
That "passes here" observation was an artifact of the maintainer's machine. There is a long-running Postgres on
127.0.0.1:5432, which is exactly the application default inapp/database.py:7. CI passes for the same reason —ci.ymlruns apostgres:16-alpineservice container published on 5432.Point
DATABASE_URLat a closed port and the contributor reports reproduce exactly:test_smoke.pydrives the real startup path —models.Base.metadata.create_all(bind=database.engine)plus tenant and admin seeding — throughTestClient, so it opens a genuine connection. Its own docstring said "Requires a reachable Postgres instance" all along.CONTRIBUTING.mdsaid the opposite.The second trap
make dbpublishes Postgres on 55432 (PG_PORT ?= 55432); the application default is 5432.make testpassesDATABASE_URLexplicitly so it works — but the command printed intest_smoke.py's own docstring did not set it. Follow that docstring after runningmake dband it targets the wrong port and fails, with the database sitting right there.Changes
CONTRIBUTING.md— remove the claim that the suite needs no database; nametest_smoke.pyas the one test that does; show the exactOperationalErrorso it reads as expected rather than as a broken checkout; document the port mismatch and the correct direct-pytestinvocation; add a--ignoreone-liner for a fully database-free run.control-plane/tests/test_smoke.py— docstring now carries aDATABASE_URLthat matchesmake db.Docs only; no test or application behaviour changed.
Verification
Both commands in the new instructions were run as written.
Worth a follow-up
Right now a contributor without Postgres gets a red
OperationalError. Makingtest_smoke.pyskip with a clear reason when the database is unreachable — guarded by an env var set in CI so a genuinely broken CI database still fails loudly — would turn a discouraging first run into130 passed, 1 skipped. Not included here since it changes test behaviour and CI config; happy to open it separately.