Repository navigation
fix(tests): skip database-backed tests when Postgres is unreachable (#150) - #151
Conversation
…aaval#150) Signed-off-by: HeaTTap <[email protected]>
|
Merged — thanks @HeaTTap, and sorry this sat for a week. That was my fault, not yours: your first PR from a fork needs a maintainer to approve the workflow runs before CI will start, and I didn't notice it was sitting in that state. Nothing was wrong with the PR the whole time it looked stalled. I verified both directions rather than take the description's word for it, and both hold:
That second one is the part that makes this a real fix rather than a papered-over one — a skip-on-unreachable guard that also silences CI would have been worse than the original problem. Setting the env var in Three things I'd tidy in a follow-up, none of them blockers:
If you'd like to take any of those, say so and I'll assign it — (3) is the one with actual substance. Otherwise I'll file it. Good first contribution: you found the pain point, fixed it, and closed the CI hole it would have opened. |
Adds release-notes entries for the five contributor PRs merged today: Grype ingestion (#123, @Diyaaa-12), combo-escalation remediation and rule catalog (#133, @Maqbool61), the combination-takeover fixture (#152, @Maqbool61), the Postgres-unreachable test skip (#151, @HeaTTap — first contribution), and the CIS 5.1.6 acceptance check moving into CI (#124, @donkk11). Also records the fixture-comment correction from #157. Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
Closes #150
Problem
When running
pytest tests/locally without a running Postgres database,tests/test_smoke.pyfails with a red stack trace (sqlalchemy.exc.OperationalError: Connection refused), surprising first-time contributors.Solution
SELECT 1) incontrol-plane/tests/test_smoke.py. If Postgres is unreachable andKAAVAL_REQUIRE_DBis not set to"1", pytest skips with:"no reachable Postgres (set DATABASE_URL; see CONTRIBUTING.md)"KAAVAL_REQUIRE_DB: "1"in.github/workflows/ci.ymlso an unreachable database in CI fails loudly rather than skipping silently.create_allintests/test_error_surfacing.pyand added DB reachability checks for database-dependent feed tests.Verification
pytest tests/without Postgres locally:127 passed, 4 skipped.KAAVAL_REQUIRE_DB=1 pytest tests/test_smoke.pywithout Postgres: fails loudly (1 failed).git commit -s).