Repository navigation
Conversation
Generated-By: GLM 5.3 High Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…backed tests Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Database tests will run if BOTH: 1. they are not specifically excluded using the `database` label 2. the `COLLECTOSS_TEST_DB` environment variable is present and contains a database URL to connect to Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…rk in the future Signed-off-by: Adrian Edwards <adredwar@redhat.com>
e2869df to
314909f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Dev10-sys
left a comment
There was a problem hiding this comment.
The docker-compose setup and dedicated CI service container job look great. Left a few inline notes on fixture scoping, fallback credentials, and parallel schema isolation vs truncate.
| test_db_name = "test_db_template_" + uuid.uuid4().hex | ||
| create_database(conn, cursor, test_db_name) | ||
| @pytest.fixture(scope="session") | ||
| def db_session(database_engine): |
There was a problem hiding this comment.
Should db_session be function-scoped rather than session-scoped? If a test mutates state or errors mid-transaction, a session-scoped session will retain cached entities in its identity map or remain in an aborted transaction state (InFailedSqlTransaction) for subsequent tests.
Generated-By: GLM 5.3 High Co-Authored-By: Dev10-sys <kalpanagola9897@gmail.com> Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…e env var is not present Generated-By: GLM 5.3 High Co-Authored-By: Dev10-sys <kalpanagola9897@gmail.com> Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…nstances Generated-By: GLM 5.3 High Co-Authored-By: Dev10-sys <kalpanagola9897@gmail.com> Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
… tests as DB tests Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Generated-By: GLM 5.3 High Co-Authored-By: Dev10-sys <kalpanagola9897@gmail.com> Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Generated-By: GLM 5.3 High Co-Authored-By: Dev10-sys <kalpanagola9897@gmail.com> Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…schemas Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
… session fixture better Signed-off-by: Adrian Edwards <adredwar@redhat.com>
a52d827 to
fc1178c
Compare
fixtures that depend on other fixtures shadow their names in their parameters this is normal and expected and reviewdog shouldn't flag it. Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…o-skipping Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
|
@Dev10-sys ok, i think i have essentially incorporated the structure from your PR into this one (and also built on it, by creating a whole group of fixtures that build CollectOSS-specific schema). This required adding a feature to make the randomization of the schema names optional because the CollectOSS schema is pretty much hardcoded to use three specific schema names ( I also removed some of the stuff surrounding passing the DB url in via CLI args (until theres a concrete need for it - to keep maintainance surface manageable and not overcompicate the docs for newcomers) Curious what you think of this version of the test fixtures! |
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
The previous guidance was bad Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…something important Signed-off-by: Adrian Edwards <adredwar@redhat.com>
| The full set of commands needed to run the database-backed tests locally are: | ||
| .. code-block:: bash | ||
|
|
||
| docker compose -f tests/docker-compose.yml up -d |
There was a problem hiding this comment.
Should we add --wait here (matching the comment in tests/docker-compose.yml)? Without --wait, docker compose up -d returns before postgres finishes initdb, which can cause a quick connection race if someone runs uv run pytest right after.
There was a problem hiding this comment.
does --wait work with -d?
There was a problem hiding this comment.
Yep, --wait works with -d in Docker Compose v2 (it actually implies -d). It starts the container in the background and waits for the pg_isready healthcheck to pass before exiting.
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Description
This PR adds the following things:
docker-compose.ymlcontaining a postgres DB for use in testingThis PR fixes #577
The testing infrastructure in this PR is helpful for testing some upcoming critical changes, such as #580 and #450
Notes for Reviewers
I have yet to evaluate how these tests interact with @EngCaioFonseca's code coverage changes.doneBecause the CollectOSS-specific tests create and drop schemas regularly, including the same names that the live CollectOSS schema uses, it WILL cause damage if it is pointed at a database that matters. That is why it uses a different environment variable for specifying a test database (maybe the wording of this var should be more strongly indicating danger)
If the database tests fail or are killed halfway through, the next run will try to create one of these identically named schemas (assuming an empty db), when it encounters the one that already exists in the DB, the tests will crash with a duplicate schema error. This "bug" is being left in on purpose to hopefully warn users that something may already exist and avoid unintended data loss.
Signed commits
Generative AI disclosure
Please select one option:
If AI tools were used, please provide details below:
- What tools were used? Cursor, GLM 5.3 High
- How were these tools used? Probably code gen, Integrating the ideas from #582 to deduplicate the PRs
- Did you review these outputs before submitting this PR? This PR is based on changes that were drafted out a long time ago, i have been through it a few times since to clean it up and test it. this cleanup was done without AI assistance. The integration of the other PRs changes was started with AI and organized/selected by me when organizing them into commits.