testcontainers / testcontainers/testcontainers-python

mongodb testcontainers cannot run in GitLab - while postgres can

Ouverte
#386 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

🐛 bug 📦 package: mongodb 🔀 requires triage
Langage dominant
Python
Étoiles
2.3k
Forks
386
Merge moyen
4 h 40 min
PR mergées (30 j)
1

Description

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:
https://github.com/testcontainers/testcontainers-python/blob/928af5a88393d8223a0d5a55e9378941826997ec/mongodb/tests/test_mongodb.py#L57

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par mongodb/tests/test_mongodb.py au niveau du test lié et reproduisez-le dans le job GitLab dind fourni ; comparez son comportement avec celui du test PostgreSQL. Suivez la gestion du port exposé du conteneur MongoDB et vérifiez la correction en réexécutant pytest dans ce pipeline sans le délai d’expiration du mappage de port.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
docker, gitlab, mongodb, python
Domaine
databases, devops, testing
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.