testcontainers-scala icon indicating copy to clipboard operation
testcontainers-scala copied to clipboard

Not recognizing DockerComposeContainer with any upper case identifier as started

Open JLofgren opened this issue 5 years ago • 0 comments

I created a DockerComposeContainer and gave it an explicit identifier of SomeCamelCaseName.

  override val container: Container = DockerComposeContainer(
    composeFiles = new File("../docker/docker-compose-it.yml"),
    exposedServices = Seq(ExposedService("my-service", 9109)),
    identifier = "SomeCamelCaseName",
    env = dockerEnv,
    pull = false,
  )

When the test runs, the container actually started, but docker identifies it having the all-lowercase name somecamelcasename... So, TestContainers thinks the container never started.

Something along the docker start path is converting the name to lowercase, but the live-checking code doesn't do the same.

info] com.acme.DockerItSpec *** ABORTED ***
[info]   org.testcontainers.containers.ContainerLaunchException: Container startup failed
[info]   at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:307)
[info]   at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:287)
[info]   at org.testcontainers.containers.DockerComposeContainer.startAmbassadorContainers(DockerComposeContainer.java:316)
[info]   at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:157)
[info]   at com.dimafeng.testcontainers.DockerComposeContainer.start(DockerComposeContainer.scala:112)
[info]   at com.dimafeng.testcontainers.ForAllTestContainer.run(ForAllTestContainer.scala:17)
[info]   at com.dimafeng.testcontainers.ForAllTestContainer.run$(ForAllTestContainer.scala:13)
[info]   at com.acme.DockerItSpec.run(DockerItSpec.scala:13)
[info]   at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:314)
[info]   at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:507)
[info]   ...
[info]   Cause: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
[info]   at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
[info]   at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:300)
[info]   at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:287)
[info]   at org.testcontainers.containers.DockerComposeContainer.startAmbassadorContainers(DockerComposeContainer.java:316)
[info]   at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:157)
[info]   at com.dimafeng.testcontainers.DockerComposeContainer.start(DockerComposeContainer.scala:112)
[info]   at com.dimafeng.testcontainers.ForAllTestContainer.run(ForAllTestContainer.scala:17)
[info]   at com.dimafeng.testcontainers.ForAllTestContainer.run$(ForAllTestContainer.scala:13)
[info]   at com.acme.DockerItSpec.run(DockerItSpec.scala:13)
[info]   at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:314)
[info]   ...
[info]   Cause: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
[info]   at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:418)
[info]   at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:302)
[info]   at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
[info]   at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:300)
[info]   at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:287)
[info]   at org.testcontainers.containers.DockerComposeContainer.startAmbassadorContainers(DockerComposeContainer.java:316)
[info]   at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:157)
[info]   at com.dimafeng.testcontainers.DockerComposeContainer.start(DockerComposeContainer.scala:112)
[info]   at com.dimafeng.testcontainers.ForAllTestContainer.run(ForAllTestContainer.scala:17)
[info]   at com.dimafeng.testcontainers.ForAllTestContainer.run$(ForAllTestContainer.scala:13)
[info]   ...
[info]   Cause: org.testcontainers.containers.ContainerLaunchException: Aborting attempt to link to container SomeCamelCaseNameyybsfu_my-service_1 as it is not running
[info]   at org.testcontainers.containers.GenericContainer.applyConfiguration(GenericContainer.java:654)
[info]   at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:336)
[info]   at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:302)
[info]   at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
[info]   at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:300)
[info]   at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:287)
[info]   at org.testcontainers.containers.DockerComposeContainer.startAmbassadorContainers(DockerComposeContainer.java:316)
[info]   at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:157)
[info]   at com.dimafeng.testcontainers.DockerComposeContainer.start(DockerComposeContainer.scala:112)
[info]   at com.dimafeng.testcontainers.ForAllTestContainer.run(ForAllTestContainer.scala:17)
[info]   ...

Even after the test exits, the container is still running, but it has an all-lowercase name:

$ docker ps
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS              PORTS                    NAMES
fc9bea4d86f0        my-service:0.1.0-SNAPSHOT   "/opt/docker/bin/my-…"   5 minutes ago       Up 5 minutes        0.0.0.0:9109->9109/tcp   somecamelcasenameyybsfu_my-service_1

JLofgren avatar Jan 11 '20 14:01 JLofgren