| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Replace deprecated @wait_container_is_ready decorator in PostgresContainer with new ExecWaitStrategy for checking database readiness. - Add ExecWaitStrategy to core wait_strategies module for command-based readiness checks - Update PostgresContainer._connect() to use ExecWaitStrategy with psql - Remove dependency on deprecated wait_container_is_ready decorator - Strategy executes psql command to verify database is accepting connections - Add runtime check for exec support (DockerContainer only) The new ExecWaitStrategy is reusable for any DockerContainer that needs to execute commands to check readiness (databases, CLI tools, etc). Note: ExecWaitStrategy requires containers with exec support and will not work with ComposeContainer. The runtime check provides a clear error if used incorrectly.
Codecov Report❌ Patch coverage is 10.71429% with 25 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## main #935 +/- ##
==========================================
- Coverage 79.78% 78.18% -1.60%
==========================================
Files 14 14
Lines 1182 1210 +28
Branches 184 187 +3
==========================================
+ Hits 943 946 +3
- Misses 197 222 +25
Partials 42 42 ☔ View full report in Codecov by Sentry.
|
Sorry, something went wrong.
🤖 I have created a release *beep* *boop* --- ## [4.14.0](testcontainers-v4.13.3...testcontainers-v4.14.0) (2026-01-07) ### Features * Add ExecWaitStrategy and migrate Postgres from deprecated decorator ([#935](#935)) ([2d9eee3](2d9eee3)) ### Bug Fixes * add ruff to deps ([#919](#919)) ([5853d32](5853d32)) * **cassandra,mysqk,kafka:** Use wait strategy instead of deprecated wait_for_logs ([#945](#945)) ([b7791b9](b7791b9)) * **core:** recreate poetry lockfile with latest versions of libraries ([#946](#946)) ([9a97385](9a97385)) * **elasticsearch:** Use wait strategy instead of deprecated decorator ([#915](#915)) ([c785ecd](c785ecd)) * **minio:** minio client requires kwargs now ([#933](#933)) ([37f5902](37f5902)) * **minio:** Use wait strategy instead of deprecated decorator ([#899](#899)) ([febccb7](febccb7)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…943) # fix(mongodb): Use wait strategy instead of deprecated wait_for_logs ## Summary Replace the deprecated `wait_for_logs` function with `LogMessageWaitStrategy` in the MongoDB container module. This is part of a fix for #874 and similar to: - #899 (MinIO - merged) - #915 (Elasticsearch - merged) - #935 (Postgres - merged) - #903 (Kafka/Redpanda - open) - #914 (Redis - open) - #941 (Redis - open) ## Changes - Import `LogMessageWaitStrategy` instead of `wait_for_logs` - Pass `_wait_strategy=LogMessageWaitStrategy(...)` to parent constructor - Override `_connect()` with empty implementation (DbContainer's base implementation uses SQLAlchemy which doesn't apply to MongoDB) ## Testing All existing MongoDB tests pass: ``` poetry run pytest modules/mongodb/tests/ -v ======================== 4 passed in 16.26s ======================== ``` No deprecation warnings from testcontainers after this change. Co-authored-by: David Ankin <daveankin@gmail.com>
| Back | FazBrowse Home | New Git URL |
Problem
The PostgresContainer currently uses the deprecated @wait_container_is_ready() decorator, which is slated for removal. The container was previously migrated away from log-based waiting due to
locale-dependent issues (#703, #695), but still relies on the deprecated decorator pattern.
Solution
This PR introduces a new ExecWaitStrategy wait strategy and migrates PostgresContainer to use it.
Changes
New ExecWaitStrategy in core/testcontainers/core/wait_strategies.py
Updated modules/postgres/testcontainers/postgres/__init__.py
Design Consideration: Protocol Limitations
Issue: The WaitStrategyTarget protocol is designed to support both DockerContainer and ComposeContainer, but ExecWaitStrategy only works with DockerContainer (which has an exec()
method).
Current Solution: Runtime check with hasattr(container, "exec") that raises a clear error if used with incompatible containers.
Discussion Points:
I've opted for the runtime check to maintain consistency with the existing WaitStrategyTarget protocol pattern, but I'm open to alternatives if the maintainers prefer a different approach.
PR Checklist
as we make use of this for detecting Semantic Versioning changes.
all community features will be tagged community-feat,
but we do not want to release minor or major versions due to features or breaking changes outside of core.
So please use fix(postgres): or fix(my_new_vector_db): if you want to add or modify community modules.
This may change in the future if we have a separate package released with community modules.
(if unsure, look at other existing community modules)
and you DO NOT have an __init__.py above your module's level.
we still prefer adding NO EXTRA DEPENDENCIES, meaning mymodule = [] is the preferred addition
(see the notes at the bottom)