Skip to content

Commit

Permalink
Change Maven config to allow skipping Lucene or Elasticsearch tests f…
Browse files Browse the repository at this point in the history
…rom the Maven CLI
  • Loading branch information
yrodiere committed Sep 20, 2023
1 parent 7b705ae commit d87e279
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 17 deletions.
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ and run unit tests and integration tests.
./mvnw clean install
```

Note: on Windows, you will need a Docker install able to run Linux containers.
If you don't have that, you can skip the Elasticsearch tests:
`./mvnw clean install -Dtest.elasticsearch.skip=true`.

Note: the produced JARs are compatible with Java 8 and later,
regardless of the JDK used to build Hibernate Search.

Expand Down Expand Up @@ -302,6 +306,17 @@ Or more simply, if the newer JDK you want to test against is newer than 17 and i
./mvnw clean install -Djava-version.test.release=18
```

### Lucene

The Lucene integration tests do not, by themselves,
require any external setup.

If you are not interested in Lucene integration tests (e.g. you only want to test Elasticsearch),
you can skip all Lucene tests with:

```bash
./mvnw clean install -Dtest.lucene.skip=true
```
### Elasticsearch

The Elasticsearch integration tests run against one single version of Elasticsearch at a time,
Expand All @@ -324,6 +339,13 @@ For available versions of [OpenSearch](https://www.opensearch.org/) distribution

For Amazon OpenSearch Serverless, the version must be unset (set to an empty string).

When necessary (e.g. you don't have Docker, or are on Windows and can't run Linux containers),
you can skip all Elasticsearch tests (and thus the Elasticsearch container startup) with:

```bash
./mvnw clean install -Dtest.elasticsearch.skip=true
```

Alternatively, you can prevent the build from launching an Elasticsearch server automatically
and run Elasticsearch-related tests against your own server using the
`test.elasticsearch.connection.uris` property:
Expand Down
18 changes: 14 additions & 4 deletions build/parents/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,27 @@
<!-- Containers executions tests properties -->
<test.containers.run.skip>false</test.containers.run.skip>

<!-- Lucene tests properties -->

<!-- To skip all Lucene tests from the CLI -->
<test.lucene.skip>false</test.lucene.skip>

<!-- Elasticsearch tests properties -->

<!-- To skip all Elasticsearch tests from the CLI -->
<test.elasticsearch.skip>false</test.elasticsearch.skip>

<!-- Control how an Elasticsearch instance is run automatically during tests -->
<!-- By default, the plugin is not skipped, but each container (elastic, opensearch, etc.) is skipped;
Maven profiles will re-enable the right container depending on configuration.
-->
<test.elasticsearch.run.skip>true</test.elasticsearch.run.skip>

<!-- If an external connection url is defined this property will be true -->
<!-- See elasticsearch-run and elasticsearch-do-not-run profiles -->
<test.elasticsearch.connection.uris.defined></test.elasticsearch.connection.uris.defined>
<!-- This is set to true automatically when the Elasticsearch instance should not be started
even for modules that include Elasticsearch tests,
be it because Elasticsearch tests are disabled
or because an Elasticsearch instance is provided externally.
See elasticsearch-run, elasticsearch-test-skip and elasticsearch-do-not-run profiles -->
<test.elasticsearch.run.skip.forRelevantModules>false</test.elasticsearch.run.skip.forRelevantModules>

<!--
These properties are transparently passed as system properties to integration tests,
Expand Down
17 changes: 15 additions & 2 deletions build/parents/integrationtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@
</activation>
<properties>
<test.elasticsearch.connection.uris>http://localhost:9200</test.elasticsearch.connection.uris>
<test.elasticsearch.connection.uris.defined>false</test.elasticsearch.connection.uris.defined>
</properties>
</profile>
<!-- Profile enabled when an Elasticsearch instance must NOT be run by Maven -->
Expand All @@ -480,7 +479,21 @@
</property>
</activation>
<properties>
<test.elasticsearch.connection.uris.defined>true</test.elasticsearch.connection.uris.defined>
<test.elasticsearch.run.skip.forRelevantModules>true</test.elasticsearch.run.skip.forRelevantModules>
</properties>
</profile>
<!-- Profile enabled when Elasticsearch tests are skipped -->
<profile>
<id>elasticsearch-test-skip</id>
<activation>
<!-- Activate if test.elasticsearch.connection.uris has been defined explicitly -->
<property>
<name>test.elasticsearch.skip</name>
<value>true</value>
</property>
</activation>
<properties>
<test.elasticsearch.run.skip.forRelevantModules>true</test.elasticsearch.run.skip.forRelevantModules>
</properties>
</profile>

Expand Down
4 changes: 3 additions & 1 deletion documentation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<description>Hibernate Search reference documentation</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<asciidoctor.base-output-dir>${project.build.directory}/asciidoctor/</asciidoctor.base-output-dir>
Expand Down Expand Up @@ -128,6 +128,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-lucene</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-elasticsearch</classpathDependencyExclude>
Expand All @@ -146,6 +147,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-elasticsearch</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-lucene</classpathDependencyExclude>
Expand Down
3 changes: 2 additions & 1 deletion integrationtest/backend/elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<properties>
<surefire.module>elasticsearch</surefire.module>

<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
</properties>

<dependencies>
Expand Down Expand Up @@ -72,6 +72,7 @@
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
<!-- WARNING: When using <dependenciesToScan>, be sure to set the Maven property surefire.module -->
<dependenciesToScan>
<dependency>${project.groupId}:hibernate-search-integrationtest-backend-tck</dependency>
Expand Down
1 change: 1 addition & 0 deletions integrationtest/backend/lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
<!-- WARNING: When using <dependenciesToScan>, be sure to set the Maven property surefire.module -->
<dependenciesToScan>
<dependency>${project.groupId}:hibernate-search-integrationtest-backend-tck</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<description>Hibernate Search integration tests for Java 11+ modules</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<maven.compiler.release>11</maven.compiler.release>
Expand Down Expand Up @@ -89,6 +89,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
5 changes: 4 additions & 1 deletion integrationtest/java/modules/orm-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<description>Hibernate Search integration tests for Java 11+ modules</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<maven.compiler.release>11</maven.compiler.release>
Expand Down Expand Up @@ -71,6 +71,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
3 changes: 3 additions & 0 deletions integrationtest/java/modules/orm-lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<description>Hibernate Search integration tests for Java 11+ modules</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<maven.compiler.release>11</maven.compiler.release>
Expand Down Expand Up @@ -63,6 +63,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
3 changes: 3 additions & 0 deletions integrationtest/java/modules/pojo-standalone-lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion integrationtest/mapper/orm-batch-jsr352/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<description>Hibernate Search integration tests for the Batch JSR-352 integration</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<surefire.jvm.args.module>
Expand Down
34 changes: 33 additions & 1 deletion integrationtest/mapper/orm-realbackend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
<description>Hibernate Search integration tests for the Hibernate ORM mapper with a real (non-mock) backend</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<!-- See profiles below -->
<test.multiplebackends.skip>false</test.multiplebackends.skip>
</properties>

<dependencies>
Expand Down Expand Up @@ -77,6 +80,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-lucene</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-elasticsearch</classpathDependencyExclude>
Expand All @@ -96,6 +100,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-elasticsearch</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-lucene</classpathDependencyExclude>
Expand All @@ -115,6 +120,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.multiplebackends.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-multiplebackends</reportNameSuffix>
<includes>
<include>org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.BackendTypeAutoDetectMultipleBackendTypesInClasspathIT</include>
Expand All @@ -138,5 +144,31 @@
</plugins>
</build>

<profiles>
<profile>
<id>skipLuceneTests</id>
<activation>
<property>
<name>test.lucene.skip</name>
<value>true</value>
</property>
</activation>
<properties>
<test.multiplebackends.skip>true</test.multiplebackends.skip>
</properties>
</profile>
<profile>
<id>skipElasticsearchTests</id>
<activation>
<property>
<name>test.elasticsearch.skip</name>
<value>true</value>
</property>
</activation>
<properties>
<test.multiplebackends.skip>true</test.multiplebackends.skip>
</properties>
</profile>
</profiles>
</project>

16 changes: 15 additions & 1 deletion integrationtest/mapper/orm-spring-uberjar/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -123,5 +122,20 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>skipLuceneTests</id>
<activation>
<property>
<name>test.lucene.skip</name>
<value>true</value>
</property>
</activation>
<properties>
<failsafe.spring.skip>true</failsafe.spring.skip>
</properties>
</profile>
</profiles>
</project>

4 changes: 3 additions & 1 deletion integrationtest/mapper/pojo-standalone-realbackend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<description>Hibernate Search integration tests for the POJO Standalone mapper with a real (non-mock) backend</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
</properties>

<dependencies>
Expand Down Expand Up @@ -63,6 +63,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-lucene</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-elasticsearch</classpathDependencyExclude>
Expand All @@ -81,6 +82,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-elasticsearch</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-lucene</classpathDependencyExclude>
Expand Down
5 changes: 4 additions & 1 deletion integrationtest/performance/backend/elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!-- We don't want to use a Jacoco agent here, and we don't want to rely on these tests for coverage either -->
<jacoco.skip>true</jacoco.skip>

<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
</properties>

<dependencies>
Expand Down Expand Up @@ -59,6 +59,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
3 changes: 3 additions & 0 deletions integrationtest/performance/backend/lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
Loading

0 comments on commit d87e279

Please sign in to comment.