Skip to content

Kubernetes Support #449

Closed
Closed

Description

@Jotschi

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.

Activity

  1. bsideup commented on Aug 29, 2017

    @bsideup
    Member

    Hi @Jotschi,

    Thanks for reporting! We added pre-flight checks and did a couple of fixes in 1.4.x, could you please update to 1.4.2, so that we see that it also fails? Thanks!

  2. Jotschi commented on Aug 29, 2017

    @Jotschi
    Author

    @bsideup Same error using version 1.4.2:

    org.testcontainers.containers.ContainerLaunchException: Container startup failed
    	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:189)
    	at com.gentics.mesh.distributed.containers.MeshDockerServer.start(MeshDockerServer.java:163)
    	at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:544)
    	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:182)
    	... 11 more
    Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
    	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:256)
    	at org.testcontainers.containers.GenericContainer.lambda$start$0(GenericContainer.java:184)
    	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:32789 should be listening)
    	at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:91)
    	at org.testcontainers.containers.GenericContainer$AbstractWaitStrategy.waitUntilReady(GenericContainer.java:943)
    	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:466)
    	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:235)
    	... 14 more
    

    Earlier I see the following messages:

            ℹ︎ Checking the system...
            ✔ Docker version is newer than 1.6.0
            ✔ Docker environment has more than 2GB free
            ✔ File should be mountable
            ✔ Exposed port is accessible
    
  3. bsideup commented on Aug 29, 2017

    @bsideup
    Member

    @Jotschi interesting! "Exposed port is accessible" passed. It means that it works, in general, just you container failed to expose the port. Does it work locally?

  4. Jotschi commented on Aug 29, 2017

    @Jotschi
    Author

    @bsideup The Test runs just fine locally. What is that check actually doing?

  5. bsideup commented on Aug 29, 2017

    @bsideup
    Member

    @Jotschi it starts a container and checks that the port is accessible, with exactly the same approach we use to expose ports from GenericContainers. If it passes - I would check container's configuration first because it seems that networking is not the root cause of the issue you have

  6. Jotschi commented on Aug 30, 2017

    @Jotschi
    Author

    @bsideup Yes you were right. The issue I'm seeing seems to be related to the container I'm running. The application is not starting correctly and thus the startup check fails.

  7. Jotschi commented on Sep 13, 2017

    @Jotschi
    Author

    @bsideup It is still not working for me but I assume it is a problem with my setup and the used data volume permissions. I'll close the issue. Thank you for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions