testcontainers / testcontainers/testcontainers-python
mongodb testcontainers cannot run in GitLab - while postgres can
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 386
- Merge trung bình
- 4 giờ 40 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với mongodb/tests/test_mongodb.py tại test được liên kết và tái hiện nó trong GitLab dind job được cung cấp; so sánh hành vi của nó với test PostgreSQL. Truy vết cách xử lý cổng được expose của container MongoDB và xác minh bản sửa bằng cách chạy lại pytest trong pipeline đó mà không có timeout ánh xạ cổng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, gitlab, mongodb, python
- Lĩnh vực
- databases, devops, testing
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100