diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe29d51dafc..e2626a78d79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,8 +36,13 @@ concurrency: group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}" cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-search' }} +defaults: + run: + shell: bash + env: MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end" + jobs: build: name: ${{matrix.os.name}} @@ -51,13 +56,26 @@ jobs: runs-on: 'ubuntu-latest', java: { version: 17 + }, + maven: { + args: '' } } + # We can't start Linux containers on GitHub Actions' Windows VMs, + # so we can't run Elasticsearch tests. + # See https://github.com/actions/runner-images/issues/1143#issuecomment-972929995 + # For some reason docker-maven-plugin will error out with "All pipe instances are busy" + # on GitHub Actions' Windows VMs (when using Bash?), + # so we also explicitly disable docker-maven-plugin. + # See https://github.com/fabric8io/docker-maven-plugin/issues/548#issuecomment-255477600 - { name: "Windows JDK 17", runs-on: 'windows-latest', java: { version: 17 + }, + maven: { + args: '-Dtest.elasticsearch.skip=true -Dtest.containers.run.skip=true' } } steps: @@ -86,10 +104,12 @@ jobs: - name: Docker cleanup run: ./ci/docker-cleanup.sh - name: Building code and running unit tests and basic checks - run: ./mvnw $MAVEN_ARGS install -Pjqassistant -Pdist -Pci-sources-check -DskipITs + run: | + ./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} install \ + -Pjqassistant -Pdist -Pci-sources-check -DskipITs - name: Running integration tests in the default environment run: | - ./mvnw $MAVEN_ARGS verify \ + ./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} verify \ -DskipSurefireTests -Pskip-checks -Pci-rebuild \ ${{ github.event.pull_request.base.ref && format('-Dincremental -Dgib.referenceBranch=refs/remotes/origin/{0}', github.event.pull_request.base.ref) || '' }} - name: Docker cleanup @@ -97,11 +117,21 @@ jobs: run: ./ci/docker-cleanup.sh - name: Omit produced artifacts from build cache run: rm -r ~/.m2/repository/org/hibernate/search + # Workaround for https://github.com/actions/upload-artifact/issues/240 + - name: List build reports to upload (if build failed) + if: ${{ failure() || cancelled() }} + # The weird syntax is because we're setting a multiline environment variable + # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string + run: | + { + echo 'buildReportPaths<> "$GITHUB_ENV" - name: Upload build reports (if build failed) uses: actions/upload-artifact@v3 if: ${{ failure() || cancelled() }} with: - name: ${{ format('build-reports-{0}', github.job) }} - path: | - ./**/*-reports/ - retention-days: 2 + name: ${{ format('build-reports-{0}', matrix.os.name ) }} + path: ${{ env.buildReportPaths }} + retention-days: 7 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c22e7884906..63f41aeb387 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 and all container startups: +`./mvnw clean install -Dtest.elasticsearch.skip=true -Dtest.containers.run.skip=true`. + Note: the produced JARs are compatible with Java 8 and later, regardless of the JDK used to build Hibernate Search. @@ -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, @@ -324,6 +339,19 @@ 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 +``` + +On Windows, you might need to also skip all docker container features: + +```bash +./mvnw clean install -Dtest.elasticsearch.skip=true -Dtest.containers.run.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: diff --git a/build/parents/build/pom.xml b/build/parents/build/pom.xml index af82792ed75..50859f113f9 100644 --- a/build/parents/build/pom.xml +++ b/build/parents/build/pom.xml @@ -183,17 +183,27 @@ false + + + + false + + + false + true - - - - + + false @@ -480,7 +479,21 @@ - true + true + + + + + elasticsearch-test-skip + + + + test.elasticsearch.skip + true + + + + true diff --git a/documentation/pom.xml b/documentation/pom.xml index 745c0a0af4d..a9cb5a08ea6 100644 --- a/documentation/pom.xml +++ b/documentation/pom.xml @@ -20,7 +20,7 @@ Hibernate Search reference documentation - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} false ${project.build.directory}/asciidoctor/ @@ -128,6 +128,7 @@ integration-test + ${test.lucene.skip} ${surefire.reportNameSuffix}-lucene org.hibernate.search:hibernate-search-backend-elasticsearch @@ -146,6 +147,7 @@ integration-test + ${test.elasticsearch.skip} ${surefire.reportNameSuffix}-elasticsearch org.hibernate.search:hibernate-search-backend-lucene diff --git a/integrationtest/backend/elasticsearch/pom.xml b/integrationtest/backend/elasticsearch/pom.xml index f4f22a06788..69d479e99f1 100644 --- a/integrationtest/backend/elasticsearch/pom.xml +++ b/integrationtest/backend/elasticsearch/pom.xml @@ -15,7 +15,7 @@ elasticsearch - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} @@ -72,6 +72,7 @@ verify + ${test.elasticsearch.skip} ${project.groupId}:hibernate-search-integrationtest-backend-tck diff --git a/integrationtest/backend/lucene/pom.xml b/integrationtest/backend/lucene/pom.xml index 8c7c2e709b3..e05b425ff24 100644 --- a/integrationtest/backend/lucene/pom.xml +++ b/integrationtest/backend/lucene/pom.xml @@ -52,6 +52,7 @@ verify + ${test.lucene.skip} ${project.groupId}:hibernate-search-integrationtest-backend-tck diff --git a/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/pom.xml b/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/pom.xml index 213572f469a..7bce2dd9dc4 100644 --- a/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/pom.xml +++ b/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/pom.xml @@ -17,7 +17,7 @@ Hibernate Search integration tests for Java 11+ modules - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} false 11 @@ -89,6 +89,9 @@ integration-test verify + + ${test.elasticsearch.skip} + diff --git a/integrationtest/java/modules/orm-elasticsearch/pom.xml b/integrationtest/java/modules/orm-elasticsearch/pom.xml index 7be3fa94079..ff8f331278c 100644 --- a/integrationtest/java/modules/orm-elasticsearch/pom.xml +++ b/integrationtest/java/modules/orm-elasticsearch/pom.xml @@ -17,7 +17,7 @@ Hibernate Search integration tests for Java 11+ modules - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} false 11 @@ -71,6 +71,9 @@ integration-test verify + + ${test.elasticsearch.skip} + diff --git a/integrationtest/java/modules/orm-lucene/pom.xml b/integrationtest/java/modules/orm-lucene/pom.xml index 62ca9eb3e30..42099857889 100644 --- a/integrationtest/java/modules/orm-lucene/pom.xml +++ b/integrationtest/java/modules/orm-lucene/pom.xml @@ -66,6 +66,9 @@ integration-test verify + + ${test.lucene.skip} + diff --git a/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml b/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml index ea149b8e7ba..e3af263297e 100644 --- a/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml +++ b/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml @@ -17,7 +17,7 @@ Hibernate Search integration tests for Java 11+ modules - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} false 11 @@ -63,6 +63,9 @@ integration-test verify + + ${test.elasticsearch.skip} + diff --git a/integrationtest/java/modules/pojo-standalone-lucene/pom.xml b/integrationtest/java/modules/pojo-standalone-lucene/pom.xml index 35e6acea286..dff13b01c0b 100644 --- a/integrationtest/java/modules/pojo-standalone-lucene/pom.xml +++ b/integrationtest/java/modules/pojo-standalone-lucene/pom.xml @@ -58,6 +58,9 @@ integration-test verify + + ${test.lucene.skip} + diff --git a/integrationtest/mapper/orm-batch-jsr352/pom.xml b/integrationtest/mapper/orm-batch-jsr352/pom.xml index 3ee02cc51a4..251e1e71866 100644 --- a/integrationtest/mapper/orm-batch-jsr352/pom.xml +++ b/integrationtest/mapper/orm-batch-jsr352/pom.xml @@ -13,7 +13,7 @@ Hibernate Search integration tests for the Batch JSR-352 integration - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} false diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml b/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml index 397b80fd15d..11af0318c9a 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml +++ b/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml @@ -78,9 +78,9 @@ - %regex[org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/.*IT\.class] + %regex[org[/\\]hibernate[/\\]search[/\\]integrationtest[/\\]mapper[/\\]orm[/\\]coordination[/\\]outboxpolling[/\\].*IT\.class] - %regex[org/hibernate/search/integrationtest/mapper/orm/automaticindexing/.*IT\.class] + %regex[org[/\\]hibernate[/\\]search[/\\]integrationtest[/\\]mapper[/\\]orm[/\\]automaticindexing[/\\].*IT\.class] @@ -111,4 +111,19 @@ + + + windows + + + windows + + + + + true + + + + diff --git a/integrationtest/mapper/orm-realbackend/pom.xml b/integrationtest/mapper/orm-realbackend/pom.xml index c846cd2ef2d..8b09f9a6ec4 100644 --- a/integrationtest/mapper/orm-realbackend/pom.xml +++ b/integrationtest/mapper/orm-realbackend/pom.xml @@ -13,8 +13,11 @@ Hibernate Search integration tests for the Hibernate ORM mapper with a real (non-mock) backend - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} false + + + false @@ -77,6 +80,7 @@ integration-test + ${test.lucene.skip} ${surefire.reportNameSuffix}-lucene org.hibernate.search:hibernate-search-backend-elasticsearch @@ -96,6 +100,7 @@ integration-test + ${test.elasticsearch.skip} ${surefire.reportNameSuffix}-elasticsearch org.hibernate.search:hibernate-search-backend-lucene @@ -115,11 +120,10 @@ integration-test + ${test.multiplebackends.skip} ${surefire.reportNameSuffix}-multiplebackends org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.BackendTypeAutoDetectMultipleBackendTypesInClasspathIT - org.hibernate.search.integrationtest.mapper.orm.realbackend.schema.management.ElasticsearchSchemaManagerExporterIT - org.hibernate.search.integrationtest.mapper.orm.realbackend.schema.management.LuceneSchemaManagerExporterIT @@ -138,5 +142,31 @@ + + + skipLuceneTests + + + test.lucene.skip + true + + + + true + + + + skipElasticsearchTests + + + test.elasticsearch.skip + true + + + + true + + + diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java index 65d172ee5d7..3f891bbae93 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java @@ -14,15 +14,18 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; import jakarta.persistence.EntityManagerFactory; +import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.integrationtest.mapper.orm.realbackend.testsupport.BackendConfigurations; import org.hibernate.search.integrationtest.mapper.orm.realbackend.util.Article; import org.hibernate.search.integrationtest.mapper.orm.realbackend.util.Book; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; @@ -35,7 +38,10 @@ public class ElasticsearchSchemaManagerExporterIT { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @Rule - public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); + public OrmSetupHelper setupHelper = OrmSetupHelper.withMultipleBackends( + BackendConfigurations.simple(), + Map.of( Article.BACKEND_NAME, BackendConfigurations.simple() ) + ); private EntityManagerFactory entityManagerFactory; @@ -51,15 +57,11 @@ public void elasticsearch() throws IOException { String version = ElasticsearchTestDialect.getActualVersion().toString(); entityManagerFactory = setupHelper.start() // so that we don't try to do anything with the schema and allow to run without ES being up: - .withProperty( "hibernate.search.schema_management.strategy", "none" ) - - .withProperty( "hibernate.search.backend.type", "elasticsearch" ) - .withProperty( "hibernate.search.backend.version_check.enabled", false ) - .withProperty( "hibernate.search.backend.version", version ) - - .withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".type", "elasticsearch" ) - .withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".version_check.enabled", false ) - .withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".version", version ) + .withProperty( HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, "none" ) + .withBackendProperty( ElasticsearchBackendSettings.VERSION_CHECK_ENABLED, false ) + .withBackendProperty( ElasticsearchBackendSettings.VERSION, version ) + .withBackendProperty( Article.BACKEND_NAME, ElasticsearchBackendSettings.VERSION_CHECK_ENABLED, false ) + .withBackendProperty( Article.BACKEND_NAME, ElasticsearchBackendSettings.VERSION, version ) .setup( Book.class, Article.class ); Path directory = temporaryFolder.newFolder().toPath(); diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java index e99adca80c4..413f8809bb5 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -31,17 +32,16 @@ public class LuceneSchemaManagerExporterIT { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @Rule - public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); + public OrmSetupHelper setupHelper = OrmSetupHelper.withMultipleBackends( + BackendConfigurations.simple(), + Map.of( Article.BACKEND_NAME, BackendConfigurations.simple() ) + ); private EntityManagerFactory entityManagerFactory; @Test public void lucene() throws IOException { - entityManagerFactory = setupHelper.start() - .withProperty( "hibernate.search.backend.type", "lucene" ) - - .withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".type", "lucene" ) - .setup( Book.class, Article.class ); + entityManagerFactory = setupHelper.start().setup( Book.class, Article.class ); Path directory = temporaryFolder.newFolder().toPath(); Search.mapping( entityManagerFactory ).scope( Object.class ).schemaManager().exportExpectedSchema( directory ); diff --git a/integrationtest/mapper/orm-spring-uberjar/application/pom.xml b/integrationtest/mapper/orm-spring-uberjar/application/pom.xml index 126b59883ea..34a230d6cef 100644 --- a/integrationtest/mapper/orm-spring-uberjar/application/pom.xml +++ b/integrationtest/mapper/orm-spring-uberjar/application/pom.xml @@ -68,7 +68,6 @@ - @@ -123,5 +122,20 @@ + + + + skipLuceneTests + + + test.lucene.skip + true + + + + true + + + diff --git a/integrationtest/mapper/pojo-standalone-realbackend/pom.xml b/integrationtest/mapper/pojo-standalone-realbackend/pom.xml index 9c687e374c6..48963149289 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/pom.xml +++ b/integrationtest/mapper/pojo-standalone-realbackend/pom.xml @@ -13,7 +13,7 @@ Hibernate Search integration tests for the POJO Standalone mapper with a real (non-mock) backend - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} @@ -63,6 +63,7 @@ integration-test + ${test.lucene.skip} ${surefire.reportNameSuffix}-lucene org.hibernate.search:hibernate-search-backend-elasticsearch @@ -81,6 +82,7 @@ integration-test + ${test.elasticsearch.skip} ${surefire.reportNameSuffix}-elasticsearch org.hibernate.search:hibernate-search-backend-lucene diff --git a/integrationtest/performance/backend/elasticsearch/pom.xml b/integrationtest/performance/backend/elasticsearch/pom.xml index e300f8603d1..0b150dbcef0 100644 --- a/integrationtest/performance/backend/elasticsearch/pom.xml +++ b/integrationtest/performance/backend/elasticsearch/pom.xml @@ -22,7 +22,7 @@ true - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} @@ -59,6 +59,9 @@ integration-test verify + + ${test.elasticsearch.skip} + @@ -134,4 +137,19 @@ + + + windows + + + windows + + + + + true + + + + diff --git a/integrationtest/performance/backend/lucene/pom.xml b/integrationtest/performance/backend/lucene/pom.xml index 02b8dee266c..51143b3621d 100644 --- a/integrationtest/performance/backend/lucene/pom.xml +++ b/integrationtest/performance/backend/lucene/pom.xml @@ -53,6 +53,9 @@ integration-test verify + + ${test.lucene.skip} + @@ -124,4 +127,19 @@ + + + windows + + + windows + + + + + true + + + + diff --git a/integrationtest/showcase/library/pom.xml b/integrationtest/showcase/library/pom.xml index 044f7cd3d6c..3260aa0f778 100644 --- a/integrationtest/showcase/library/pom.xml +++ b/integrationtest/showcase/library/pom.xml @@ -13,7 +13,7 @@ Hibernate Search showcase based on the ORM and Elasticsearch integrations, using libraries and books as business objects - ${test.elasticsearch.connection.uris.defined} + ${test.elasticsearch.run.skip.forRelevantModules} false @@ -207,6 +208,7 @@ integration-test + ${test.elasticsearch.skip} ${surefire.reportNameSuffix}-elasticsearch diff --git a/integrationtest/v5migrationhelper/engine/pom.xml b/integrationtest/v5migrationhelper/engine/pom.xml index 2bcf836901d..fb440121b3e 100755 --- a/integrationtest/v5migrationhelper/engine/pom.xml +++ b/integrationtest/v5migrationhelper/engine/pom.xml @@ -78,6 +78,7 @@ verify + ${test.lucene.skip} **/*IT.java