我有一个Spring Boot应用程序测试,该测试使用TestContainers(https://www.testcontainers.org)对KafkaContainer运行一些集成测试。在本地运行时,一切都很好,但是在GitlabCI管道中运行集成测试时,容器无法启动。这是作业日志:
> 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)
此处是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
此处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
有帮助吗? 谢谢
答案 0 :(得分:0)
我知道您现在可能已经解决了这个问题,但是给您一个答案,以备日后参考,以防其他人遇到同样的问题。
我遇到了类似的问题,并通过为容器添加自定义等待策略和/或自定义超时来解决此问题。在我的机器上本地可以正常运行,但是在速度较慢的gitlab.com共享运行程序上,它将超时
Wait.forHttp("/health").withStartupTimeout(Duration.ofMinutes(5L))