Pin the testcontainers Postgres in the URL-fixture test to _POSTGRES_IMAGE

Open Beginner friendly
#3,620 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, postgresql, python
Domain
testing-qa

Research direction

Start with the bare postgres:17 literal in tests/db/test_postgres_url_fixture.py near line 197 and switch it to db_conftest._POSTGRES_IMAGE, which that module already imports. Then extend the scan in tests/guards/test_fixture_image_pins.py over tests/**/*.py for PostgresContainer( calls with bare tags. Done when the test uses the pinned constant and the guard fails once the bare tag is put back.

Written by the indexing model from the issue text.

Description

area:core-platform effort:S priority:P3 risk:night-safe status:ready type:test

Problem

tests/db/test_postgres_url_fixture.py still starts a testcontainers Postgres from the bare tag postgres:17. #3610 / PR #3613 pinned the compose and fixture Postgres images to the digest-pinned _POSTGRES_IMAGE in tests/db/conftest.py, because an upstream re-tag of postgres:17 to 17.12 broke fresh migrations. This test was not included. It also is not pre-pulled, so it can pull a different, unpinned image from the one the rest of the suite uses.

Evidence

  • tests/db/test_postgres_url_fixture.py:197: with PostgresContainer("postgres:17") as container:
  • tests/db/conftest.py:41-43: _POSTGRES_IMAGE = ("postgres:17@sha256:7958…3317" # 17), the pinned constant. tests/db/conftest.py:58 uses it for the session fixture.
  • tests/guards/test_fixture_image_pins.py:40-43: the guard checks only the _POSTGRES_IMAGE / _SEAWEEDFS_IMAGE constants in the two conftest files, plus the compose/Helm references added by #3610. It does not scan test modules for a bare PostgresContainer("postgres:...").

Expected

Every Postgres testcontainer in the tree uses the digest-pinned _POSTGRES_IMAGE, and the pin guard fails when a test starts one from a bare tag.

Proposed approach

  1. In tests/db/test_postgres_url_fixture.py:197, use db_conftest._POSTGRES_IMAGE (the module already imports db_conftest).
  2. Extend tests/guards/test_fixture_image_pins.py so it scans tests/**/*.py for PostgresContainer( calls (and postgres: image literals) that do not use the constant or a digest pin. Prove the guard bites by restoring the bare tag and watching it fail.
Dominant language
Python
Stars
0
Forks
0
Avg merge
9h 13m
Merged PRs (30d)
197

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from randomparity/kdive

All issues in randomparity/kdive

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.