test(api): isolate container DB between tests#36310
Merged
asukaminato0721 merged 3 commits intoMay 18, 2026
Merged
Conversation
Contributor
Pyrefly Type Coverage
|
asukaminato0721
approved these changes
May 18, 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.
Summary
Part of #32454 (comment). Draft follow-up to #36308.
This adds a central DB isolation fixture for container integration tests. After each test that used the containerized Flask app, the fixture truncates SQLAlchemy application tables and restarts identities.
The cleanup transaction sets
SET LOCAL lock_timeout = '5s'so leaked sessions or open transactions fail CI loudly instead of causing a long hang.Design
flask_app_with_containers, so tests that do not use the containerized app do not start the full stack just because the cleanup fixture exists.db.metadata; Redis, object storage, and custom ad hoc metadata remain separate cleanup concerns.Review order
Please review and merge #36308 first. This branch is stacked on top of that service fix branch; after #36308 merges, this PR should reduce to the container DB isolation change.
A diagnostic version of this cleanup is recorded in #36304. That draft intentionally applies the cleanup before the session fixes, so it can expose the existing leaked-session failure mode.
Validation
uv run --project api ruff check api/services/attachment_service.py api/services/file_service.py api/tests/test_containers_integration_tests/conftest.pyuv run --project api python -m compileall -q api/services/attachment_service.py api/services/file_service.py api/tests/test_containers_integration_tests/conftest.py