Skip to content

Commit 1388612

Browse files
fix(mongo): mongo start waiting forever for old mongo versions (#783)
Old versions of Mongo, like 3.6, log the message "waiting for connections [...]", with a lowercase 'w', while newer versions log the message with uppercase 'W'. This commit makes the log search when starting the container case insensitive. Co-authored-by: Roy Moore <[email protected]>
1 parent e6b976d commit 1388612

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/mongodb/testcontainers/mongodb/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# License for the specific language governing permissions and limitations
1212
# under the License.
1313
import os
14+
import re
1415
from typing import Optional
1516

1617
from pymongo import MongoClient
@@ -77,7 +78,12 @@ def get_connection_url(self) -> str:
7778
)
7879

7980
def _connect(self) -> None:
80-
wait_for_logs(self, "Waiting for connections")
81+
regex = re.compile(r"waiting for connections", re.MULTILINE | re.IGNORECASE)
82+
83+
def predicate(text: str) -> bool:
84+
return regex.search(text) is not None
85+
86+
wait_for_logs(self, predicate)
8187

8288
def get_connection_client(self) -> MongoClient:
8389
return MongoClient(self.get_connection_url())

0 commit comments

Comments
 (0)