Skip to content

Commit

Permalink
Add tests on OSS image as well
Browse files Browse the repository at this point in the history
Previously we were testing the code with x-pack and without.
We can still do that by pulling the right Docker image anytime we want to start integration tests.

This is available with a new Maven profile `oss`.

We also move the `docker-maven-plugin` to the parent pom so we can reuse this configuration in other modules.
There is not other one yet but I'm thinking of building at the end a FSCrawler Docker image which I can start for real and run more advanced integration tests.
  • Loading branch information
dadoonet committed Feb 22, 2018
1 parent 4c5be50 commit 5a0da02
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 45 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ addons:
before_script:
- sudo sysctl -w vm.max_map_count=262144
script:
- mvn --batch-mode clean verify -Pes-5x && mvn --batch-mode clean verify
- mvn --batch-mode clean verify -Pes-5x
- mvn --batch-mode clean verify -Poss
- mvn --batch-mode clean verify
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
after_success:
- "[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] && [[ ${TRAVIS_TAG} == '' ]] && mvn deploy -DskipTests --settings deploy-settings.xml"
Expand Down
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ You can also tell maven to run integration tests by deploying another version of
mvn install -Pes-5x
```

By default, it will run integration tests against elasticsearch 6.x series cluster.
By default, it will run integration tests against elasticsearch 6.x series cluster protected with X-Pack.

You can also run test without X-Pack by using the `oss` maven profile:

```sh
mvn install -Poss
```

### Running tests against an external cluster

Expand Down
43 changes: 1 addition & 42 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,51 +100,10 @@
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>

<!-- To start Docker when running IT -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.24.0</version>
<configuration>
<images>
<image>
<alias>elasticsearch-it</alias>
<name>dadoonet/docker-elasticsearch:${project.version}</name>
<build>
<from>docker.elastic.co/elasticsearch/elasticsearch:${integ.elasticsearch.version}</from>
</build>
<run>
<ports>
<port>integ.elasticsearch.port:9200</port>
</ports>
<wait>
<http>
<url>http://localhost:${integ.elasticsearch.port}/</url>
<status>200..499</status>
</http>
<time>60000</time>
</wait>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>start-elasticsearch</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-elasticsearch</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
57 changes: 56 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
<skipTests>false</skipTests>
<skipUnitTests>${skipTests}</skipUnitTests>
<skipIntegTests>${skipTests}</skipIntegTests>
<skipXPack>true</skipXPack>

<!-- For integration tests using Docker or external cluster -->
<integ.elasticsearch.image>docker.elastic.co/elasticsearch/elasticsearch</integ.elasticsearch.image>
<integ.elasticsearch.version>${elasticsearch.version}</integ.elasticsearch.version>
<integ.security.username>elastic</integ.security.username>
<integ.security.password>changeme</integ.security.password>
Expand Down Expand Up @@ -223,6 +223,55 @@
</executions>
</plugin>

<!-- For IT using Docker -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.24.0</version>
<configuration>
<images>
<image>
<alias>elasticsearch-it</alias>
<name>dadoonet/docker-elasticsearch:${project.version}</name>
<build>
<from>${integ.elasticsearch.image}:${integ.elasticsearch.version}</from>
</build>
<run>
<ports>
<port>integ.elasticsearch.port:9200</port>
</ports>
<wait>
<http>
<url>http://localhost:${integ.elasticsearch.port}/</url>
<status>200..499</status>
</http>
<time>60000</time>
</wait>
</run>
</image>
</images>
<skip>${skipIntegTests}</skip>
</configuration>
<executions>
<execution>
<id>start-elasticsearch</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-elasticsearch</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Generate the release zip file (run during package step) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -626,6 +675,12 @@
</repositories>

<profiles>
<profile>
<id>oss</id>
<properties>
<integ.elasticsearch.image>docker.elastic.co/elasticsearch/elasticsearch-oss</integ.elasticsearch.image>
</properties>
</profile>
<profile>
<id>es-5x</id>
<properties>
Expand Down

0 comments on commit 5a0da02

Please sign in to comment.