Reputation: 135
I have a Spring Boot application test that used TestContainers (https://www.testcontainers.org) to run some integration tests against a KafkaContainer. When running locally everything is fine, but when running integration test inside a GitlabCI pipeline the container can't start. Here the job log:
> org.testcontainers.containers.ContainerLaunchException: Container > startup failed Caused by: > org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with > exception Caused by: > org.testcontainers.containers.ContainerLaunchException: Could not > create/start container Caused by: > org.testcontainers.containers.ContainerLaunchException: Timed out > waiting for container port to open (docker ports: [32776, 32778] > should be listening)
Here Gitlab CI conf:
image: docker:git
services:
- docker:dind
stages:
- test
- push
- deploy
variables:
MAVEN_CLI_OPTS: "--batch-mode -Dmaven.repo.local=/.m2"
DOCKER_HOST: "tcp://docker:2375"
DOCKER_DRIVER: overlay2
.test_template: &java_test
image: maven:3.5.3-jdk-8
stage: test
tags:
- test
myapp-api_test:
<<: *java_test
services:
- docker:dind
variables:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_DRIVER: overlay2
script:
- cd myapp-api
- mvn $MAVEN_CLI_OPTS package
Here Runner conf:
executor = "docker"
[runners.docker]
tls_verify = false
image = "alpine:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache", "/.m2",
"/var/run/docker.sock:/var/run/docker.sock"]
shm_size = 0
output_limit = 8192
Any help? Thanks
Upvotes: 3
Views: 1576
Reputation: 3558
I know you've probably figured this out by now, but giving you an answer for future reference in case others find themselves in the same kind of problem.
I was having similar issues, and fixed it by adding a custom waitstrategy and/or custom timeout for my containers. Locally on my machine it would work fine, but on the slower gitlab.com shared runners it would timeout
Wait.forHttp("/health").withStartupTimeout(Duration.ofMinutes(5L))
Upvotes: 0