testcontainers / testcontainers/testcontainers-python

mongodb testcontainers cannot run in GitLab - while postgres can

Aperta
#386 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

🐛 bug 📦 package: mongodb 🔀 requires triage
Lingua principale
Python
Stelle
2.3k
Fork
386
Merge medio
4h 40m
PR unite (30g)
1

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con mongodb/tests/test_mongodb.py nel test collegato e riproducilo nel job GitLab dind fornito; confronta il suo comportamento con quello del test PostgreSQL. Traccia la gestione della porta esposta del container MongoDB e verifica la correzione rieseguendo pytest in quella pipeline senza il timeout del port mapping.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
docker, gitlab, mongodb, python
Ambito
databases, devops, testing
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.