testcontainers / testcontainers/testcontainers-python
mongodb testcontainers cannot run in GitLab - while postgres can
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 2.3k
- Forks
- 386
- Merge medio
- 4 h 40 min
- PR fusionados (30 d)
- 1
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con mongodb/tests/test_mongodb.py en el test enlazado y reprodúcelo en el job de GitLab dind proporcionado; compara su comportamiento con el test de PostgreSQL. Rastrea la gestión del puerto expuesto del contenedor de MongoDB y verifica la corrección volviendo a ejecutar pytest en ese pipeline sin el tiempo de espera del mapeo de puertos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- docker, gitlab, mongodb, python
- Área
- databases, devops, testing
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100