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</version>
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>Await</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>false</skip>
<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>
<mysqlConnections>
<mysqlConnection>
<host>localhost</host>
<port>3306</port>
<database>mysql</database>
<username>root</username>
<password>password</password>
<query>select 1</query>
</mysqlConnection>
</mysqlConnections>
</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.
- a mysql client connection to jdbc:mysql://localhost:3306/mysql?username=root&password=password with successful response to query "select 1".
The plugin will make 3 attempts on to reach each service, waiting 1000ms between each try.
Boolean value indicating whether to skip all connection checks.
<skip>false</skip>
Time to wait (in ms) before polling begins.
<initialWait>0</initialWait>
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>
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>
Boolean value indicating whether to skip this specific connection.
<skip>false</skip>
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 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>
Boolean value indicating whether to skip this specific connection.
<skip>false</skip>
A collection of mysqlConnection elements.
A mysql connection configuration.
<mysqlConnection>
<host>localhost</host>
<port>3306</port>
<database>mysql</database>
<username>root</username>
<password>password</password>
<query>select 1</query>
</mysqlConnection>
The mysql host.
<host>localhost</host>
The mysql port.
<port>3306</port>
The mysql database to which to include in the connection string.
<database>mysql</database>
The mysql username used to login.
<username>root</username>
The mysql password used to login.
<password>password</password>
The mysql query to run to verify the connection.
<query>select 1</query>
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>
Boolean value indicating whether to skip this specific connection.
<skip>false</skip>
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>
<configuration>
<skip>${maven.test.skip}</skip>
</configuration>
</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>
<skip>${maven.test.skip}</skip>
<initialWait>5000</initialWait>
<poll>
<attempts>3</attempts>
<sleep>5000</sleep>
</poll>
<httpConnections>
<httpConnection>
<url>http://localhost:27080</url>
<statusCode>200</statusCode>
</httpConnection>
</httpConnections>
</configuration>
</plugin>
</plugins>
</build>