You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(mongodb): waiting for container to start (it was not waiting at all 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 <sparekh@oneweb.net>
0 commit comments