Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb testcontainers cannot run in GitLab - while postgres can #386

Open
simcax opened this issue Oct 13, 2023 · 1 comment
Open

mongodb testcontainers cannot run in GitLab - while postgres can #386

simcax opened this issue Oct 13, 2023 · 1 comment

Comments

@simcax
Copy link

simcax commented Oct 13, 2023

Describe the bug

Launching MongoDB Testcontainer in GitLab with dind yields error: "Exception: port mapping for container xxxx and port 27017 is not available" - i.e.:

"testcontainers.core.exceptions.TimeoutException: Wait time (120s) exceeded for get_exposed_port(args: (27017,), kwargs {}). Exception: port mapping for container afa0edc97197698ae51ad40d64a8f2b37de2a52027d3cb9f4c9e9959442a9b8d and port 27017 is not available"

Expected test to run as it does in the local test with docker.
Tried running the postgres testcontainer in the same test file and pipeline, which works. So am suspecting an issue with the mongodb testcontainer implementation.

To Reproduce

Add the test from here:

def test_docker_run_mongodb_connect_without_credentials():

And the postgres test which works from here:
https://testcontainers-python.readthedocs.io/en/latest/postgres/README.html

And run in GitLab pipeline with:

.test:
  services:
     - name: docker:dind
       command: ["--tls=false"]
  
  variables:
    DOCKER_HOST: "tcp://docker:2375"
    DOCKER_TLS_CERTDIR: ""
    DOCKER_DRIVER: overlay2

  image: python:3.12.0-slim-bookworm
 
  script:
    - python -m pip install poetry
    - poetry install --with dev
    - poetry run pytest .

Runtime environment

Running GitLab Community version 16.4.0 with GitLab runners and docker in docker.
Testcontainers version 3.7.1
Python 3.12.0
pymongo 4.5.0

@covatic-john
Copy link

#401

I was having issue with mongo this may help

currently writing as test to support the bug I raised

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants