service | master | dev |
---|---|---|
CI Build | ||
Test |
await-maven-plugin is a plugin to pause maven build until some service is available.
<plugin>
<groupId>com.github.slem1</groupId>
<artifactId>await-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>Await</goal>
</goals>
</execution>
</executions>
<configuration>
<awaitSkip>false</awaitSkip>
<poll>
<attempts>3</attempts>
<sleep>1000</sleep>
</poll>
<tcpConnections>
<tcpConnection>
<host>localhost</host>
<port>5432</port>
</tcpConnection>
</tcpConnections>
<httpConnections>
<httpConnection>
<url>http://mywebservice:9090</url>
<statusCode>200</statusCode>
</httpConnection>
</httpConnections>
</configuration>
</plugin>
With the above configuration, the maven build will pause after process-test-classes and wait for the availability of two services:
- a tcp service on localhost:5432 (postgres)
- a 200 OK http response from http://mywebservice:9090.
The plugin will make 3 attempts on to reach each service, waiting 1000ms between each try.
Set to true if you want to skip plugin execution. Can also be passed as -DawaitSkip
<awaitSkip>true</awaitSkip>
The polling configuration object. Apply to each service to contact.
<poll>
<attempts>3</attempts>
<sleep>1000</sleep>
</poll>
Max number of attempts to reach a service.
<attempts>3</attempts>
Time to wait (in ms) between two attempts.
<sleep>1000</sleep>
Default behaviour is to throw an exception if all attemps fail. You can override this with the throwOnFail setting. This is useful when you run services in a docker container and need a cleanup step in the 'post-integration-test' phase.
<throwOnFail>false<throwOnFail>
A collection of tcpConnection elements.
A tcp connection configuration.
<tcpConnection>
<host>localhost</host>
<port>5432</port>
</tcpConnection>
The tcp host.
<host>localhost</host>
The tcp port.
<port>5432</port>
Defines the order in which the connection will be attempted across tcpConnection and httpConnection. The 0 value is the highest priority. By default, if not defined, the priority is the lowest (Integer.MAX_VALUE).
<priority>100</priority>
A collection of http or https connections.
The configuration of a connection to a service running on http.
<httpConnection>
<url>http://mywebservice:9090</url>
<statusCode>200</statusCode>
</httpConnection>
The service URL.
<url>http://mywebservice:9090</url>
The service URL can include basic auth information when running on http
<url>http://user:pass@mywebservice:9090</url>
The expected status code response.
<statusCode>200</statusCode>
Defines the order in which the connection will be attempted across tcpConnection and httpConnection. The 0 value is the highest priority. By default, if not defined, the priority is the lowest (Integer.MAX_VALUE).
<priority>100</priority>
Set true if you want to skip SSL certificate verification.
<skipSSLCertVerification>true</skipSSLCertVerification>
Wait for a docker container startup and service up with docker-compose-maven-plugin before running integration tests.
<build>
<plugins>
<plugin>
<groupId>com.dkanejs.maven.plugins</groupId>
<artifactId>docker-compose-maven-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<composeFile>../docker/docker-compose.yml</composeFile>
<detachedMode>true</detachedMode>
</configuration>
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>up</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.slem1</groupId>
<artifactId>await-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>Await</goal>
</goals>
</execution>
</executions>
<configuration>
<poll>
<attempts>3</attempts>
<sleep>5000</sleep>
</poll>
<httpConnections>
<httpConnection>
<url>http://localhost:27080</url>
<statusCode>200</statusCode>
</httpConnection>
</httpConnections>
</configuration>
</plugin>
</plugins>
</build>