-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
It seems that testcontainers-java does not work well in a kubernetes environment. I run my tests on a jenkins which uses the jenkins kubernetes-plugin to provide slaves.
I'm by fare not an export in kubernetes and/or docker but I think I have an idea why testcontainers-java is not working. Please correct me if I may mix up things.
The jenkins-slave which runs maven and executes my tests is managed by kubernetes. The network of this docker container is managed by flannel and thus the network device of the slave container is not attached to the docker0 bridge. Instead it is being attached to the flannel bridge device.
It seems that it is not possible to (by default) to connect from a kubernetes managed container to a pure docker container. Thus the connection from my jenkins-slave container to 172.17.0.1:32785 fails.
testcontainers-java version: 1.3.0
org.testcontainers.containers.ContainerLaunchException: Container startup failed
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:179)
at com.gentics.mesh.distributed.containers.MeshDockerServer.start(MeshDockerServer.java:147)
at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:531)
at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:83)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:172)
... 11 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:246)
at org.testcontainers.containers.GenericContainer.lambda$start$0(GenericContainer.java:174)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
... 12 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1:32785 should be listening)
at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:90)
at org.testcontainers.containers.GenericContainer$AbstractWaitStrategy.waitUntilReady(GenericContainer.java:910)
at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:453)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:225)
... 14 more
The best solution (afaik) would be to create the testcontainer via kubernetes API instead of docker. This way the testcontainer would utilize the flannel network and could be reached.