【问题标题】:Issue when executing Gitlab CI pipeline job running integration test with Testcontainers使用 Testcontainers 执行运行集成测试的 Gitlab CI 管道作业时出现问题
【发布时间】:2019-09-05 12:57:18
【问题描述】:

我有一个 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

在这里亚军会议:

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

有什么帮助吗? 谢谢

【问题讨论】:

    标签: spring-boot docker gitlab-ci testcontainers


    【解决方案1】:

    我知道你现在可能已经想通了,但给你一个答案以供将来参考,以防其他人发现自己遇到同样的问题。

    我遇到了类似的问题,并通过为我的容器添加自定义等待策略和/或自定义超时来修复它。在我的机器上本地它可以正常工作,但在较慢的 gitlab.com 共享运行器上它会超时

    Wait.forHttp("/health").withStartupTimeout(Duration.ofMinutes(5L))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 2021-05-15
      • 2019-09-28
      • 2021-03-20
      • 2020-01-27
      • 2022-10-24
      • 2021-08-19
      相关资源
      最近更新 更多