Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mongodb): waiting for container to start (it was not waiting at a…
…ll before?) (#461) we were using this code to test if it was online or not:`MongoClient(self.get_connection_url())`, but that doesn't actually perform any connection, instead you have to do something like: ```python @wait_container_is_ready() def _connect(self): client = self.get_connection_client() # will raise pymongo.errors.ServerSelectionTimeoutError if no connection is established client.admin.command('ismaster') ``` thanks to @smparekh for pointing this out, in his PR: https://github.com/testcontainers/testcontainers-python/pull/80/files#diff-cf09f76f44db0af04c58ddb456ccae39f7e29ce1d9208acd5f514c0a7dccb646R78 this PR implements the workaround described in the PR: ```python @pytest.fixture(scope="session") def test_client(): # init mongo mongo_container = MongoDbContainer("mongo:4").start() wait_for_logs(mongo_container, 'waiting for connections on port 27017') ... Co-authored-by: Shaishav Parekh <[email protected]>
- Loading branch information