How can I tell docker-maven-plugin
to wait for the RabbitMQ container to fully start up before running integration tests?
This is the plugin configuration I am using in the pom.xml
:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>start-rabbitmq-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<images>
<image>
<alias>rabbitmq</alias>
<name>rabbitmq:3.6.10-management</name>
<run>
<log>
<prefix>RABBITMQ</prefix>
<color>cyan</color>
</log>
<namingStrategy>alias</namingStrategy>
<ports>
<port>5672:5672</port>
<port>15672:15672</port>
</ports>
</run>
</image>
</images>
</configuration>
</execution>
<execution>
<id>stop-rabbitmq-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
At the moment the ITs start executing while RabbitMQ it's still initialising and failing as the server is not available.
I managed to find a more assertive way of checking for the status of RabbitMQ. As I am using the
rabbitmq:3.6.10-management
docker image, I can check that the management url onlocalhost:15672
is up:The
wait
configuration will check the return value of getting the management url, for a maximum of 10 seconds until it's within the specified HTTP response status range, but RabbitMQ normally starts up within 2 to 3 seconds.