arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
120 stars 98 forks source link

Using connectionMode 'STARTORCONNECT' and autoStartContainers #173

Closed lucasweb78 closed 8 years ago

lucasweb78 commented 9 years ago

I'm trying two support to use cases:

  1. No containers are running and I want Arquillian Cube to start and stop the containers (continuous integration)
  2. I have containers running and I want Arquillian Cube to use them. (developers running individual tests)

My arquillian.xml contains the following:

    <extension qualifier="docker">
        <property name="serverVersion">1.12</property>
        <property name="serverUri">https://192.168.99.100:2376</property>
        <property name="connectionMode">STARTORCONNECT</property>
        <property name="autoStartContainers">mysql-it,activemq-it</property>
        <property name="dockerContainers">
            wildfly:
              image: jboss/wildfly
              await:
                strategy: polling
                sleepPollingTime: 1000
                iterations: 15
              portBindings: [8081->8081/tcp, 9991->9991/tcp]
              links:
                - mysql-it:mysql-it
                - activemq-it:activemq-it
            mysql-it:
              image: mysql
              await:
                strategy: polling
                sleepPollingTime: 1000
                iterations: 15
              env: [MYSQL_ROOT_PASSWORD=password, MYSQL_DATABASE=test, MYSQL_USER=test, MYSQL_PASSWORD=-test]
              portBindings: [3307->3306/tcp]
            activemq-it:
              image: activemq
              await:
                strategy: polling
                sleepPollingTime: 1000
                iterations: 15
              portBindings: [8162->8161/tcp]
        </property>
    </extension>

    <container qualifier="wildfly" default="true">
        <configuration>
            <property name="managementPort">9991</property>
            <property name="username">admin</property>
            <property name="password">password</property>
        </configuration>
    </container>

In order to satisfy use case 1 I need to specify that I want to auto-start mysql and activemq using the autoStartContainers property. If I don't they are not automatically started even though they are linked to by Wildfly

In order to satisfy use case 2 I need to set the connectionMode to 'STARTORCONNECT' in order to connect to the running containers. The problem is that if I have autoStartContainers set and the containers are running Arquillian cube fails with the following error:

Caused by: com.github.dockerjava.api.InternalServerErrorException: Could not get container for mysql-it

    at com.github.dockerjava.core.util.ResponseStatusExceptionFilter.filter(ResponseStatusExceptionFilter.java:54)
    at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:134)
    at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:123)
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:251)
    at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:683)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:679)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:435)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:338)
    at com.github.dockerjava.jaxrs.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:31)
    at com.github.dockerjava.jaxrs.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:14)
    at com.github.dockerjava.jaxrs.AbstrDockerCmdExec.exec(AbstrDockerCmdExec.java:57)
    at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:29)
    at com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:101)
    at org.arquillian.cube.docker.impl.docker.DockerClientExecutor.createContainer(DockerClientExecutor.java:326)
    at org.arquillian.cube.docker.impl.model.DockerCube.create(DockerCube.java:74)
    at org.arquillian.cube.impl.client.CubeLifecycleController.create(CubeLifecycleController.java:15)
    at sun.reflect.Nativ

Removing autoStartContainers resolves this issue but then use case 1 no longer works.

I was also hoping to be able to manually start the wildfly container and have cube connect to it and execute the tests in it, but this does not see possible. It seems I have to let cube start and stop the container for me.

aslakknutsen commented 9 years ago

If I don't they are not automatically started even though they are linked to by Wildfly.

This issue should address that problem: https://github.com/arquillian/arquillian-cube/issues/162

Both use cases are legit, and to be honest STARTORCONNECT is suppose to cover them.. but it seems we have some 'flag soup' when combined with autoStart :)