Skip to content

Commit

Permalink
Merge pull request #11686 from machi1990/chore/add-docker-option
Browse files Browse the repository at this point in the history
Add -Ddocker option to spin a Redis Server container automatically when launching Redis IT test
  • Loading branch information
gsmet authored Aug 27, 2020
2 parents e3a4ac2 + 7dd94e1 commit c88263e
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 3 deletions.
22 changes: 19 additions & 3 deletions integration-tests/redis-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,36 @@

## Running the tests

By default, the tests of this module are disabled.
By default, the tests of this module are disabled. To activate the test, use the `-Dtest-redis` option.

NB: Tests in this module will attempt a connection to a local Redis listening on the default port.
If you have specific requirements, you can define a specific connection URL with `-Dquarkus.redis.hosts=host:port`.
Or, you can use the `-Ddocker` option to start the Redis Server container automatically.

### Running tests in JVM mode

To run, you can run the following command:

```
mvn clean install -Dtest-redis
```

NB: Tests in this module will attempt a connection to a local Redis listening on the default port.
If you have specific requirements, you can define a specific connection URL with `-Dquarkus.redis.hosts=host:port`.
Alternatively, to run the tests in JVM mode with Redis Server started as a Docker container, you can run the following command:

```
mvn clean install -Dtest-redis -Ddocker
```

### Running tests in native mode

Additionally, you can generate a native image and run the tests for this native image by adding `-Dnative`:

```
mvn clean install -Dtest-redis -Dnative
```

You can also use the `-Ddocker` system property (as shown below), if you want the Redis Server container to be started automatically.

```
mvn clean install -Dtest-redis -Dnative -Ddocker
```
82 changes: 82 additions & 0 deletions integration-tests/redis-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,88 @@
</plugins>
</build>
</profile>
<profile>
<id>docker-redis</id>
<activation>
<property>
<name>docker</name>
</property>
</activation>
<properties>
<redis.url>localhost:6379</redis.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>redis:5.0.8-alpine</name>
<alias>quarkus-test-redis</alias>
<run>
<ports>
<port>6379:6379</port>
</ports>
<log>
<prefix>Redis:</prefix>
<date>default</date>
<color>cyan</color>
</log>
<!-- Speed things up a bit by not actually flushing writes to disk -->
<wait>
<!-- good docs found at: http://dmp.fabric8.io/#start-wait -->
<time>20000</time>
<!-- wait until Redis is actually up by checking if we can ping the server-->
<exec>
<postStart>redis-cli PING</postStart>
</exec>
</wait>
</run>
</image>
</images>
<!--Stops all redis images currently running, not just those we just started.
Useful to stop processes still running from a previously failed integration test run -->
<allContainers>true</allContainers>
</configuration>
<executions>
<execution>
<id>docker-start</id>
<phase>compile</phase>
<goals>
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>docker-prune</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/../../.github/docker-prune.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>native-image</id>
Expand Down

0 comments on commit c88263e

Please sign in to comment.