fix(kafka): Use wait strategy instead of deprecated wait_for_logs by Hugo-C · Pull Request #903 · testcontainers/testcontainers-python · GitHub
Skip to content

fix(kafka): Use wait strategy instead of deprecated wait_for_logs#903

Merged
alexanderankin merged 3 commits into
testcontainers:mainfrom
Hugo-C:redpanda-wait-strategy
Apr 1, 2026
Merged

fix(kafka): Use wait strategy instead of deprecated wait_for_logs#903
alexanderankin merged 3 commits into
testcontainers:mainfrom
Hugo-C:redpanda-wait-strategy

Conversation

@Hugo-C

@Hugo-C Hugo-C commented Oct 14, 2025

Copy link
Copy Markdown
Contributor

Related to #874.

Since those containers first need to be started to know their exposed ports, we cannot use DockerContainer._wait_strategy. We have to keep checking logs manually in their own start methods.

Let me know if there is anything to change.

@codecov

codecov Bot commented Oct 15, 2025

Copy link
Copy Markdown

@Hugo-C Hugo-C changed the title Fix Kafka/Redpanda DeprecationWarning on wait_for_logs fix(kafka): Use wait strategy instead of deprecated wait_for_logs Oct 15, 2025
@Hugo-C Hugo-C force-pushed the redpanda-wait-strategy branch from c410486 to 3a67042 Compare February 3, 2026 21:53
@Hugo-C Hugo-C force-pushed the redpanda-wait-strategy branch from 3a67042 to ae1cb02 Compare February 3, 2026 22:14
@Hugo-C

Hugo-C commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

#945 Fixed Kafka but not Redpanda, so I adapted the changes accordingly.

@Hugo-C

Hugo-C commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

@alexanderankin alexanderankin merged commit 87332c1 into testcontainers:main Apr 1, 2026
9 checks passed
alexanderankin added a commit that referenced this pull request Apr 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[4.15.0-rc.1](testcontainers-v4.14.2...testcontainers-v4.15.0-rc.1)
(2026-04-07)


### Features

* **compose:** add structured container inspect information
([#897](#897))
([58459a1](58459a1))
* **core:** support SSH-based DOCKER_HOST
([#993](#993))
([d48115d](d48115d))
* **generic:** Reintroducing the generic SQL module
([#892](#892))
([2ca2321](2ca2321))
* **keycloak:** support for relative path and management relative path
([#982](#982))
([898faf6](898faf6))
* **mqtt:** MosquittoContainer: Add version 2.1.2
([#978](#978))
([af382f7](af382f7))


### Bug Fixes

* **azurite:** make visible to type checkers
([#927](#927))
([baa5668](baa5668))
* **clickhouse:** add `HttpWaitStrategy` instead of deprecated
`wait_container_is_ready`
([#962](#962))
([8034541](8034541))
* **compose:** return type in get_service_port docstring
([#939](#939))
([fed65fe](fed65fe))
* **core:** Refactor copy file
([#996](#996))
([0e0bb24](0e0bb24))
* **core:** wait for ryuk more reliably, improve tests: long_running,
filter logs
([#984](#984))
([b12ae13](b12ae13))
* **generic:** Migrate ServerContainer from deprecated decorator to
HttpWaitStrategy
([#971](#971))
([460b0d8](460b0d8))
* **kafka:** Use wait strategy instead of deprecated wait_for_logs
([#903](#903))
([87332c1](87332c1))
* **postgres:** add py.typed marker to postgres module
([#849](#849))
([c8a5bbd](c8a5bbd))
* **qdrant:** migrate Qdrant from deprecated decorator.
([#963](#963))
([407f798](407f798))
* **redis:** Use wait strategy instead of deprecated decorator
([#914](#914))
([e25713a](e25713a))
* **sftp:** Avoid using wait_for_logs in module.
([#995](#995))
([83157eb](83157eb))

---
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: David Ankin <daveankin@gmail.com>
alexanderankin added a commit that referenced this pull request Jun 3, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants