diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 142af28fe6b..62a11870375 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,6 +4,16 @@ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 +registries: + dockerhub: + type: docker-registry + url: https://registry.hub.docker.com + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_TOKEN}} + replaces-base: true + ibm: + type: docker-registry + url: https://icr.io updates: - package-ecosystem: "maven" directory: "/" @@ -99,3 +109,56 @@ updates: # See https://github.com/dependabot/dependabot-core/issues/4028 # And, additionally, it is only for performance testing. - dependency-name: "org.bsc.maven:maven-processor-plugin" + - package-ecosystem: "docker" + registries: + - dockerhub + - ibm + # For dependabot to find Docker files they all should be in the same directory. + # Dependabot is picking any files that has `dockerfile` in them. + # + # This includes only Ryuk container, hence we want it to be checked/updated at the same time when our regular java dependencies are updated + directory: "/build/container/" + schedule: + interval: "weekly" + day: "tuesday" + assignees: ["yrodiere"] + groups: + # This group combines all build containers dependencies. + build-containers: + patterns: + # Include all: + - "*" + - package-ecosystem: "docker" + registries: + - dockerhub + # For dependabot to find Docker files they all should be in the same directory. + # Dependabot is picking any files that has `dockerfile` in them. + # + # This will only include database containers, hence we check for updates only once a month: + directory: "/build/container/database" + schedule: + interval: "monthly" + assignees: ["yrodiere"] + groups: + # This group combines all database containers dependencies. + database-containers: + patterns: + # Include all: + - "*" + - package-ecosystem: "docker" + registries: + - dockerhub + # For dependabot to find Docker files they all should be in the same directory. + # Dependabot is picking any files that has `dockerfile` in them. + directory: "/build/container/search-backend" + schedule: + interval: "daily" + assignees: ["yrodiere"] + groups: + # This group combines all search backends containers dependencies. + # We will still need to create specific tickets to address these updates and do some code changes, + # so we just want to get a notification from the bot that the new versions are available. + search-backend-containers: + patterns: + # Include all: + - "*" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e875fff9a9d..7f3d51c9aae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,8 @@ on: # we'll reject such dependant PRs and send a PR ourselves. - '!dependabot/**' - 'dependabot/maven/build-dependencies-**' + - 'dependabot/docker/build-containers-**' + - 'dependabot/docker/database-containers-**' concurrency: group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}" @@ -60,16 +62,13 @@ jobs: version: 17 }, maven: { - args: '' + # Since we only start an Elasticsearch container on Linux we add the profile to enable container reuse here: + args: '-Pci-build' } } # 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', @@ -77,7 +76,7 @@ jobs: version: 17 }, maven: { - args: '-Dtest.elasticsearch.skip=true -Dtest.containers.run.skip=true' + args: '-Dtest.elasticsearch.skip=true' } } steps: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fbe28dca22..dbc264a8ed7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -223,8 +223,8 @@ and run unit tests and integration tests. ``` 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`. +If you don't have that, you can skip the Elasticsearch tests and only run tests against H2 database (without using DB containers): +`./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. @@ -346,12 +346,6 @@ you can skip all Elasticsearch tests (and thus the Elasticsearch container start ./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: @@ -403,6 +397,22 @@ Or more simply, if your AWS credentials are already stored in `~/.aws/credential -Dtest.elasticsearch.connection.aws.region= ``` +### Testcontainers + +Hibernate Search uses Testcontainers in its integration tests. +By default, testcontainers are not reusable, i.e. a container is started at the beginning of an executed test suite, +and then stopped; each execution of failsafe plugin will start/stop their own containers as well as each test module. +With [reusable testcontainers](https://java.testcontainers.org/features/reuse/) required containers will start as needed +but will not be terminated, staying available between different failsafe executions and test modules +and even after the maven build is finished. +Reusable containers must be stopped manually, if needed (e.g. with `docker stop ` +or `docker kill `). + +There are a few ways to enable reusable testcontainers: + +1. Enable reusable testcontainers in `~/.testcontainers.properties`, by adding `testcontainers.reuse.enable=true` +2. Build with `ci-build` Maven profile: `./mvnw clean install -Pci-build` + ### JQAssistant You can request static analysis and sanity checks with the `jqassistant` profile. diff --git a/Jenkinsfile b/Jenkinsfile index c5efb672179..6149984862f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -431,6 +431,7 @@ stage('Default build') { ${commonMavenArgs} \ -DskipSurefireTests \ -Pskip-checks \ + -Pci-build \ -Pci-rebuild \ ${incrementalBuild ? """ \ -Dincremental \ @@ -540,30 +541,6 @@ stage('Non-default environments') { ''' String mavenDockerArgs = "" def startedContainers = false - // DB2 setup is super slow (~5 to 15 minutes). - // We can't afford to do that once per module, - // so we start DB2 here, once and for all. - if ( buildEnv.dbName == 'db2' ) { - // Prevent the actual build from starting the DB container - mavenBuildAdditionalArgs += " -Dtest.database.run.db2.skip=true" - // Pick a module that doesn't normally execute the docker-maven-plugin, - // but that has the configuration necessary to start the DB container: - // that way, the maven-docker-plugin won't try to remove our container - // when we execute maven another time to run the tests. - // (This works because maven-docker-plugin filters containers to stop - // based on the Maven GAV coordinates of the Maven project that started that container, - // which are attached to the container thanks to a container label). - mavenDockerArgs = """ \ - -pl build/parents/integrationtest \ - -P$buildEnv.mavenProfile \ - -Dtest.database.run.db2.skip=false \ - """ - // Cleanup just in case some containers were left over from a previous build. - sh "mvn docker:stop $mavenDockerArgs" - pullContainerImages mavenDockerArgs - sh "mvn docker:start $mavenDockerArgs" - startedContainers = true - } try { mavenNonDefaultBuild buildEnv, """ \ -Pdist \ @@ -962,7 +939,7 @@ void mavenNonDefaultBuild(BuildEnvironment buildEnv, String args, List a def testSuffix = buildEnv.tag.replaceAll('[^a-zA-Z0-9_\\-+]+', '_') sh """ \ - mvn clean install -Dsurefire.environment=$testSuffix \ + mvn clean install -Pci-build -Dsurefire.environment=$testSuffix \ ${toTestJdkArg(buildEnv)} \ --fail-at-end \ $args \ diff --git a/build/container/database/cockroachdb.Dockerfile b/build/container/database/cockroachdb.Dockerfile new file mode 100644 index 00000000000..51cb0c38f1d --- /dev/null +++ b/build/container/database/cockroachdb.Dockerfile @@ -0,0 +1,3 @@ +# CockroachDB +# See https://hub.docker.com/r/cockroachdb/cockroach/tags +FROM docker.io/cockroachdb/cockroach:v23.1.11 \ No newline at end of file diff --git a/build/container/database/db2.Dockerfile b/build/container/database/db2.Dockerfile new file mode 100644 index 00000000000..30e0fa1a7e0 --- /dev/null +++ b/build/container/database/db2.Dockerfile @@ -0,0 +1,3 @@ +# DB2 +# See https://icr.io/v2/db2_community/db2/tags/list +FROM icr.io/db2_community/db2:11.5.8.0 \ No newline at end of file diff --git a/build/container/database/mariadb.Dockerfile b/build/container/database/mariadb.Dockerfile new file mode 100644 index 00000000000..bd250057e21 --- /dev/null +++ b/build/container/database/mariadb.Dockerfile @@ -0,0 +1,3 @@ +# MariaDB +# See https://hub.docker.com/_/mariadb/tags +FROM docker.io/mariadb:11.1.2 \ No newline at end of file diff --git a/build/container/database/mssql.Dockerfile b/build/container/database/mssql.Dockerfile new file mode 100644 index 00000000000..f4c6bf4119d --- /dev/null +++ b/build/container/database/mssql.Dockerfile @@ -0,0 +1,3 @@ +# MS SQL Server +# See https://hub.docker.com/_/microsoft-mssql-server +FROM docker.io/mcr.microsoft.com/mssql/server:2022-CU9-ubuntu-20.04 \ No newline at end of file diff --git a/build/container/database/mysql.Dockerfile b/build/container/database/mysql.Dockerfile new file mode 100644 index 00000000000..806077e89a4 --- /dev/null +++ b/build/container/database/mysql.Dockerfile @@ -0,0 +1,3 @@ +# MySQL +# See https://hub.docker.com/_/mysql/tags +FROM docker.io/mysql:8.1.0 \ No newline at end of file diff --git a/build/container/database/oracle.Dockerfile b/build/container/database/oracle.Dockerfile new file mode 100644 index 00000000000..5f5a8fb7395 --- /dev/null +++ b/build/container/database/oracle.Dockerfile @@ -0,0 +1,3 @@ +# Oracle +# See https://hub.docker.com/r/gvenzl/oracle-free/tags +FROM docker.io/gvenzl/oracle-free:23.3-slim-faststart \ No newline at end of file diff --git a/build/container/database/postgresql.Dockerfile b/build/container/database/postgresql.Dockerfile new file mode 100644 index 00000000000..a6851d4ed3c --- /dev/null +++ b/build/container/database/postgresql.Dockerfile @@ -0,0 +1,3 @@ +# PostgreSQL +# See https://hub.docker.com/_/postgres +FROM docker.io/postgres:16.0 \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.10.properties b/build/container/elasticsearch/env-7.10.properties deleted file mode 100644 index 2543c13954f..00000000000 --- a/build/container/elasticsearch/env-7.10.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -indices.lifecycle.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.11.properties b/build/container/elasticsearch/env-7.11.properties deleted file mode 100644 index 2543c13954f..00000000000 --- a/build/container/elasticsearch/env-7.11.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -indices.lifecycle.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.12.properties b/build/container/elasticsearch/env-7.12.properties deleted file mode 100644 index 2543c13954f..00000000000 --- a/build/container/elasticsearch/env-7.12.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -indices.lifecycle.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.13.properties b/build/container/elasticsearch/env-7.13.properties deleted file mode 100644 index 2543c13954f..00000000000 --- a/build/container/elasticsearch/env-7.13.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -indices.lifecycle.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.14.properties b/build/container/elasticsearch/env-7.14.properties deleted file mode 100644 index 2543c13954f..00000000000 --- a/build/container/elasticsearch/env-7.14.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -indices.lifecycle.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.15.properties b/build/container/elasticsearch/env-7.15.properties deleted file mode 100644 index 2543c13954f..00000000000 --- a/build/container/elasticsearch/env-7.15.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -indices.lifecycle.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.16.properties b/build/container/elasticsearch/env-7.16.properties deleted file mode 100644 index 66a62a9e8d8..00000000000 --- a/build/container/elasticsearch/env-7.16.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-7.17.properties b/build/container/elasticsearch/env-7.17.properties deleted file mode 100644 index 66a62a9e8d8..00000000000 --- a/build/container/elasticsearch/env-7.17.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.0.properties b/build/container/elasticsearch/env-8.0.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.0.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.1.properties b/build/container/elasticsearch/env-8.1.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.1.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.10.properties b/build/container/elasticsearch/env-8.10.properties deleted file mode 100644 index b6d16ea0c68..00000000000 --- a/build/container/elasticsearch/env-8.10.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ent_search.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.profiling.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.2.properties b/build/container/elasticsearch/env-8.2.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.2.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.3.properties b/build/container/elasticsearch/env-8.3.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.3.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.4.properties b/build/container/elasticsearch/env-8.4.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.4.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.5.properties b/build/container/elasticsearch/env-8.5.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.5.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.6.properties b/build/container/elasticsearch/env-8.6.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.6.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.7.properties b/build/container/elasticsearch/env-8.7.properties deleted file mode 100644 index d89332da80b..00000000000 --- a/build/container/elasticsearch/env-8.7.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.8.properties b/build/container/elasticsearch/env-8.8.properties deleted file mode 100644 index b6d16ea0c68..00000000000 --- a/build/container/elasticsearch/env-8.8.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ent_search.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.profiling.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/elasticsearch/env-8.9.properties b/build/container/elasticsearch/env-8.9.properties deleted file mode 100644 index b6d16ea0c68..00000000000 --- a/build/container/elasticsearch/env-8.9.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Disable some features that are not needed in our tests and just slow down startup -cluster.deprecation_indexing.enabled=false -indices.lifecycle.history_index_enabled=false -slm.history_index_enabled=false -stack.templates.enabled=false -xpack.ent_search.enabled=false -xpack.ml.enabled=false -xpack.monitoring.templates.enabled=false -xpack.profiling.enabled=false -xpack.watcher.enabled=false \ No newline at end of file diff --git a/build/container/ryuk.Dockerfile b/build/container/ryuk.Dockerfile new file mode 100644 index 00000000000..44017b45d48 --- /dev/null +++ b/build/container/ryuk.Dockerfile @@ -0,0 +1,7 @@ +# Ryuk +# See https://hub.docker.com/r/testcontainers/ryuk/tags +# +# IMPORTANT! When updating the version for Ryuk in this Dockerfile, +# make sure to update `TESTCONTAINERS_RYUK_CONTAINER_IMAGE` env variable set as part of maven-failsafe-plugin configuration. +# +FROM docker.io/testcontainers/ryuk:0.5.1 \ No newline at end of file diff --git a/build/container/search-backend/amazon-opensearch-serverless.Dockerfile b/build/container/search-backend/amazon-opensearch-serverless.Dockerfile new file mode 100644 index 00000000000..ab06140befd --- /dev/null +++ b/build/container/search-backend/amazon-opensearch-serverless.Dockerfile @@ -0,0 +1,7 @@ +# OpenSearch +# See https://hub.docker.com/r/opensearchproject/opensearch/tags +# +# IMPORTANT! When updating the version of OpenSearch in this Dockerfile, +# make sure to update `version.org.opensearch.latest` property in a POM file, +# and to update the version in opensearch.Dockerfile as well. +FROM docker.io/opensearchproject/opensearch:2.11.0 \ No newline at end of file diff --git a/build/container/search-backend/elastic.Dockerfile b/build/container/search-backend/elastic.Dockerfile new file mode 100644 index 00000000000..481ea461e08 --- /dev/null +++ b/build/container/search-backend/elastic.Dockerfile @@ -0,0 +1,7 @@ +# Elasticsearch +# https://hub.docker.com/r/elastic/elasticsearch/tags +# +# IMPORTANT! When updating the version of Elasticsearch in this Dockerfile, +# make sure to update `version.org.elasticsearch.latest` property in a POM file. +# +FROM docker.io/elastic/elasticsearch:8.10.4 \ No newline at end of file diff --git a/build/container/search-backend/opensearch.Dockerfile b/build/container/search-backend/opensearch.Dockerfile new file mode 100644 index 00000000000..c4af74b2b7a --- /dev/null +++ b/build/container/search-backend/opensearch.Dockerfile @@ -0,0 +1,7 @@ +# OpenSearch +# See https://hub.docker.com/r/opensearchproject/opensearch/tags +# +# IMPORTANT! When updating the version of OpenSearch in this Dockerfile, +# make sure to update `version.org.opensearch.latest` property in a POM file, +# and to update the version in amazon-opensearch-serverless.Dockerfile as well. +FROM docker.io/opensearchproject/opensearch:2.11.0 \ No newline at end of file diff --git a/build/parents/build/pom.xml b/build/parents/build/pom.xml index 33d90fae960..08ddf9eb721 100644 --- a/build/parents/build/pom.xml +++ b/build/parents/build/pom.xml @@ -119,6 +119,8 @@ 5.10.0 1.10.0 6.0.0 + + 1.19.1 2.2 5.7.0 @@ -183,9 +185,6 @@ - - false - @@ -216,7 +215,6 @@ because we will be able to change the configuration without re-compiling the configuration file (which is located in a dependency of the integration tests modules). --> - elastic @@ -684,6 +682,13 @@ pom import + + org.testcontainers + testcontainers-bom + ${version.testcontainers} + pom + import + org.mockito @@ -1182,10 +1187,24 @@ org.apache.maven.plugins maven-failsafe-plugin + + + docker.io/testcontainers/ryuk:0.5.1 + + true + ${project.version} ${test.performance.enable} ${test.elasticsearch.distribution} + ${test.elasticsearch.version} + ${test.database.run.kind} + ${rootProject.directory} @@ -1301,6 +1320,25 @@ + + ci-build + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + true + + + + + + + dependency-update diff --git a/build/parents/integrationtest/pom.xml b/build/parents/integrationtest/pom.xml index 31528a32737..4c6d1c38d2d 100644 --- a/build/parents/integrationtest/pom.xml +++ b/build/parents/integrationtest/pom.xml @@ -26,19 +26,6 @@ ${java-version.test.compiler.java_home} ${java-version.test.compiler} generate-sources - - - -Dhibernate.dialect=${db.dialect} - -Dhibernate.connection.driver_class=${jdbc.driver} - -Dhibernate.connection.url=${jdbc.url} - -Dhibernate.connection.username=${jdbc.user} - -Dhibernate.connection.password=${jdbc.pass} - -Dhibernate.connection.isolation=${jdbc.isolation} - false - - ${test.elasticsearch.run.skip} @@ -72,406 +54,20 @@ - - io.fabric8 - docker-maven-plugin - ${version.docker.maven.plugin} - - ${test.containers.run.skip} - true - - - ${test.elasticsearch.run.elastic.image.name}:${test.elasticsearch.run.elastic.image.tag} - elasticsearch - - ${test.elasticsearch.run.elastic.skip} - - WARN - single-node - - - false - - -Xms1g -Xmx1g - - false - - ${rootProject.directory}/build/container/elasticsearch/env-${parsed-version.test.elasticsearch.version.majorVersion}.${parsed-version.test.elasticsearch.version.minorVersion}.properties - /var/lib/elasticsearch - - 9200:9200 - - - Elasticsearch: - default - cyan - - - - http://localhost:9200 - GET - 200 - - - - - - - ${test.elasticsearch.run.opensearch.image.name}:${test.elasticsearch.run.opensearch.image.tag} - opensearch - - ${test.elasticsearch.run.opensearch.skip} - - WARN - single-node - - true - - true - - false - - false - - - 9200:9200 - - - OpenSearch: - default - cyan - - - - http://localhost:9200 - GET - 200 - - - - - - - ${test.database.run.postgres.image.name}:${test.database.run.postgres.image.tag} - postgres - - ${test.database.run.postgres.skip} - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - - - 5432:5432 - - - PostgreSQL: - default - blue - - - - - (?s)ready to accept connections.*ready to accept connections - - - - - ${test.database.run.mariadb.image.name}:${test.database.run.mariadb.image.tag} - mariadb - - ${test.database.run.mariadb.skip} - --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - true - - - 3306:3306 - - - MariaDB: - default - blue - - - /var/lib/mysql - - - - mysqladmin ping -h localhost -u hibernate_orm_test -phibernate_orm_test - - - - - - ${test.database.run.mysql.image.name}:${test.database.run.mysql.image.tag} - mysql - - ${test.database.run.mysql.skip} - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - true - - - 3306:3306 - - - MySQL: - default - blue - - - /var/lib/mysql - - - - mysqladmin ping -h localhost -u hibernate_orm_test -phibernate_orm_test - - - - - - ${test.database.run.db2.image.name}:${test.database.run.db2.image.tag} - db2 - - ${test.database.run.db2.skip} - - hreact - hreact - hreact - accept - - false - false - false - - - 50005:50000 - - - DB2: - default - blue - - - bridge - - true - - - .*INSTANCE.* - - - - 300000 - - - - - ${test.database.run.oracle.image.name}:${test.database.run.oracle.image.tag} - oracle - - ${test.database.run.oracle.skip} - - hibernate_orm_test - - - 1521:1521 - - - Oracle Database: - default - blue - - - - - - DATABASE IS READY TO USE! - - - - - ${test.database.run.mssql.image.name}:${test.database.run.mssql.image.tag} - mssql - - ${test.database.run.mssql.skip} - - Y - ActuallyRequired11Complexity - - - 1433:1433 - - - MS SQL Server: - default - blue - - - SQL Server is now ready for client connections - - - - - - - ${test.database.run.cockroachdb.image.name}:${test.database.run.cockroachdb.image.tag} - cockroachdb - - ${test.database.run.cockroachdb.skip} - - - start-single-node - --insecure - - --store=type=mem,size=.5 - - --max-offset=100ms - --log=sinks: {stderr: {channels: [OPS]}} - - - - - nofile - 1956 - 1956 - - - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - - - 26257:26257 - - - CockroachDB: - default - blue - - - CockroachDB node starting at - - - - - - - - docker-start - pre-integration-test - - - stop - start - - - - docker-stop - post-integration-test - - stop - - - - - - - skippingAllTests - - - skipTests - - - - - true - - - - skippingIntegrationTests - - - skipITs - - - - - true - - - - - + - elasticsearch-run - - - - !test.elasticsearch.connection.uris - - - - http://localhost:9200 - - - - - elasticsearch-do-not-run + search-container-do-not-start @@ -479,9 +75,10 @@ - true + false + elasticsearch-test-skip @@ -494,6 +91,7 @@ true + false @@ -516,47 +114,6 @@ - - opensearch - - - test.elasticsearch.distribution - opensearch - - - - ${test.elasticsearch.run.skip} - true - ${version.org.opensearch.latest} - - - - - amazon-opensearch-serverless - - - test.elasticsearch.distribution - amazon-opensearch-serverless - - - - - - - - ${test.elasticsearch.run.skip} - true - ${version.org.opensearch.latest} - - ${version.org.elasticsearch.latest} - - - @@ -570,14 +127,8 @@ - org.hibernate.dialect.H2Dialect com.h2database h2 - org.h2.Driver - jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 - sa - sa - @@ -586,15 +137,9 @@ ci-postgresql - ${test.database.run.skip} - org.hibernate.dialect.PostgreSQLDialect org.postgresql postgresql - org.postgresql.Driver - jdbc:postgresql://localhost:5432/hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - + postgresql @@ -603,15 +148,9 @@ ci-mariadb - ${test.database.run.skip} - org.hibernate.dialect.MariaDBDialect org.mariadb.jdbc mariadb-java-client - org.mariadb.jdbc.Driver - jdbc:mariadb://localhost/hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - + mariadb @@ -620,15 +159,9 @@ ci-mysql - ${test.database.run.skip} - org.hibernate.dialect.MySQLDialect com.mysql mysql-connector-j - com.mysql.jdbc.Driver - jdbc:mysql://localhost/hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - + mysql @@ -637,15 +170,9 @@ ci-db2 - ${test.database.run.skip} - org.hibernate.dialect.DB2Dialect com.ibm.db2 jcc - com.ibm.db2.jcc.DB2Driver - jdbc:db2://localhost:50005/hreact - hreact - hreact - + db2 @@ -654,15 +181,9 @@ ci-oracle - ${test.database.run.skip} - org.hibernate.dialect.OracleDialect com.oracle.database.jdbc ojdbc11 - oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/XE - SYSTEM - hibernate_orm_test - + oracle -Doracle.jdbc.timezoneAsRegion=false @@ -673,14 +194,9 @@ ci-mssql - ${test.database.run.skip} - org.hibernate.dialect.SQLServerDialect com.microsoft.sqlserver mssql-jdbc - com.microsoft.sqlserver.jdbc.SQLServerDriver - jdbc:sqlserver://localhost:1433;databaseName=tempdb;encrypt=false - sa - ActuallyRequired11Complexity + mssql @@ -689,16 +205,10 @@ ci-cockroachdb - ${test.database.run.skip} - org.hibernate.dialect.CockroachDialect org.postgresql postgresql - org.postgresql.Driver - jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable - root - - + cockroachdb diff --git a/build/parents/springtest/pom.xml b/build/parents/springtest/pom.xml index 3c451495474..2f67b9e15e0 100644 --- a/build/parents/springtest/pom.xml +++ b/build/parents/springtest/pom.xml @@ -57,6 +57,13 @@ pom import + + org.testcontainers + testcontainers-bom + ${version.testcontainers} + pom + import + org.springframework.boot spring-boot-dependencies diff --git a/ci/dependency-update/Jenkinsfile b/ci/dependency-update/Jenkinsfile index d3bf52ca64e..7f408a963e1 100644 --- a/ci/dependency-update/Jenkinsfile +++ b/ci/dependency-update/Jenkinsfile @@ -260,7 +260,7 @@ pipeline { withMavenWorkspace { pullContainerImages() sh """ \ - mvn clean install -U -Pdependency-update -Pdist -Dsurefire.environment=${normalize(env.DEPENDENCY_UPDATE_NAME)} \ + mvn clean install -U -Pdependency-update -Pdist -Pci-build -Dsurefire.environment=${normalize(env.DEPENDENCY_UPDATE_NAME)} \ --fail-at-end \ ${env[qualify('ADDITIONAL_MAVEN_ARGS')]} \ """ diff --git a/documentation/pom.xml b/documentation/pom.xml index 51c1fa8c84c..5997e483574 100644 --- a/documentation/pom.xml +++ b/documentation/pom.xml @@ -20,9 +20,6 @@ Hibernate Search reference documentation - ${test.elasticsearch.run.skip.forRelevantModules} - false - ${project.build.directory}/asciidoctor/ ${project.build.directory}/hibernate-asciidoctor-theme ${project.build.directory}/aggregated-resources @@ -103,10 +100,6 @@ - - io.fabric8 - docker-maven-plugin - org.apache.maven.plugins maven-compiler-plugin diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java index c1a7b5ffac8..ede38ab6b1c 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java @@ -7,6 +7,7 @@ package org.hibernate.search.documentation.mapper.orm.gettingstarted.withouthsearch; import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.search.documentation.testsupport.TestConfiguration.databaseConnectionProperties; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; import java.util.List; @@ -26,7 +27,8 @@ class GettingStartedWithoutHibernateSearchIT { @BeforeEach void setup() { - entityManagerFactory = Persistence.createEntityManagerFactory( "GettingStartedWithoutHibernateSearchIT" ); + entityManagerFactory = Persistence.createEntityManagerFactory( "GettingStartedWithoutHibernateSearchIT", + databaseConnectionProperties() ); } @AfterEach diff --git a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java index d503a044046..9680a3b976e 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java @@ -28,6 +28,7 @@ import org.hibernate.search.util.impl.integrationtest.common.extension.BackendSetupStrategy; import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmAssertionHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleSessionFactoryBuilder; @@ -183,6 +184,10 @@ public final class SetupContext // Ensure we don't build Jandex indexes needlessly: // discovery based on Jandex ought to be tested in real projects that don't use this setup helper. withProperty( HibernateOrmMapperSettings.MAPPING_BUILD_MISSING_DISCOVERED_JANDEX_INDEXES, false ); + + // DB properties: + DatabaseContainer.configuration().add( overriddenProperties ); + // Ensure overridden properties will be applied withConfiguration( builder -> overriddenProperties.forEach( builder::setProperty ) ); } diff --git a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java index ab75404ad64..1f6a3b2fdd8 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java @@ -11,6 +11,7 @@ import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; public final class TestConfiguration { @@ -22,8 +23,8 @@ private TestConfiguration() { * * @return Configuration properties to use when bootstrapping Hibernate ORM with JPA. */ - public static Map ormMapperProperties(TestConfigurationProvider configurationProvider) { - Map properties = new HashMap<>(); + public static Map ormMapperProperties(TestConfigurationProvider configurationProvider) { + Map properties = databaseConnectionProperties(); // Hack: override example properties set in persistence.xml properties.put( "hibernate.search.backend.hosts", "" ); @@ -40,6 +41,12 @@ public static Map ormMapperProperties(TestConfigurationProvider return properties; } + public static Map databaseConnectionProperties() { + Map properties = new HashMap<>(); + DatabaseContainer.configuration().add( properties ); + return properties; + } + /** * @param configurationProvider A test configuration provider. * @param backendConfiguration The backend configuration. diff --git a/integrationtest/backend/elasticsearch/pom.xml b/integrationtest/backend/elasticsearch/pom.xml index c8cafe310a7..e47e131f784 100644 --- a/integrationtest/backend/elasticsearch/pom.xml +++ b/integrationtest/backend/elasticsearch/pom.xml @@ -14,8 +14,6 @@ elasticsearch - - ${test.elasticsearch.run.skip.forRelevantModules} @@ -76,10 +74,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckTestRunner.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckTestRunner.java index 355ec8a59ef..f61f6a877e6 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckTestRunner.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckTestRunner.java @@ -13,17 +13,16 @@ /** * Helper for running specific TCK tests against the Elasticsearch backend from the IDE. - * - *

Adapt the classpath filter as needed to run a single test or an entire test package. - * - *

Running such tests from the IDE will require having an Elasticsearch - * node running. You can easily start one by running 'mvn elasticsearch:runforked -Des.setAwait=true' - * from this module's directory. + *

+ * Adapt the {@code @IncludeClassNamePatterns}/{@code @SelectPackages} annotation as needed + * to run a single test or an entire test package. + *

+ * Elasticsearch will be started automatically using TestContainers. * * @author Gunnar Morling */ @Suite -@SuiteDisplayName("Lucene TCK tests Runner") +@SuiteDisplayName("Elasticsearch TCK tests Runner") // Defines a "root" package, subpackages are included. Use Include/Exclude ClassNamePatterns annotations to limit the executed tests: @SelectPackages("org.hibernate.search.integrationtest.backend.tck") // Default class pattern does not include IT tests, hence we want to customize it a bit: diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java index da4935f7bb7..dabe1b14bc8 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java @@ -13,8 +13,9 @@ /** * Helper for running specific TCK tests against the Lucene backend from the IDE. - * - *

Adapt the classpath filter as needed to run a single test or an entire test package. + *

+ * Adapt the {@code @IncludeClassNamePatterns}/{@code @SelectPackages} annotation as needed + * to run a single test or an entire test package. * * @author Gunnar Morling */ diff --git a/integrationtest/java/modules/orm-elasticsearch/pom.xml b/integrationtest/java/modules/orm-elasticsearch/pom.xml index ff8f331278c..4fb80ecc456 100644 --- a/integrationtest/java/modules/orm-elasticsearch/pom.xml +++ b/integrationtest/java/modules/orm-elasticsearch/pom.xml @@ -17,9 +17,6 @@ Hibernate Search integration tests for Java 11+ modules - ${test.elasticsearch.run.skip.forRelevantModules} - false - 11 true @@ -39,6 +36,16 @@ hibernate-search-backend-elasticsearch + + + org.hibernate.search + hibernate-search-util-internal-integrationtest-mapper-orm + + + org.hibernate.search + hibernate-search-util-internal-integrationtest-backend-elasticsearch + + org.hibernate.search hibernate-search-util-internal-test-orm @@ -77,10 +84,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/java/modules/orm-elasticsearch/src/main/java/module-info.java b/integrationtest/java/modules/orm-elasticsearch/src/main/java/module-info.java index 28074f57391..9045105b059 100644 --- a/integrationtest/java/modules/orm-elasticsearch/src/main/java/module-info.java +++ b/integrationtest/java/modules/orm-elasticsearch/src/main/java/module-info.java @@ -15,6 +15,11 @@ requires org.hibernate.orm.core; requires org.hibernate.search.mapper.orm; requires org.hibernate.search.backend.elasticsearch; + // Access to testcontainers: + requires hibernate.search.util.internal.integrationtest.mapper.orm; + requires hibernate.search.util.internal.integrationtest.backend.elasticsearch; + // Since testcontainers is using log4j we need to explicitly require it to make things work: + requires org.apache.logging.log4j; /* * This is necessary in order to use SessionFactory, diff --git a/integrationtest/java/modules/orm-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/AuthorService.java b/integrationtest/java/modules/orm-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/AuthorService.java index 42bb95f8227..fabcbf10787 100644 --- a/integrationtest/java/modules/orm-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/AuthorService.java +++ b/integrationtest/java/modules/orm-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/AuthorService.java @@ -6,7 +6,9 @@ */ package org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.service; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -21,6 +23,8 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.common.AssertionFailure; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.SearchBackendContainer; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.service.spi.ServiceRegistryImplementor; public class AuthorService implements AutoCloseable { @@ -32,7 +36,7 @@ public AuthorService() { } private SessionFactory createSessionFactory() { - StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); + StandardServiceRegistryBuilder registryBuilder = applyConnectionProperties( new StandardServiceRegistryBuilder() ); ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) registryBuilder.build(); Metadata metadata = new MetadataSources( serviceRegistry ).addAnnotatedClass( Author.class ).buildMetadata(); SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder(); @@ -40,7 +44,7 @@ private SessionFactory createSessionFactory() { } public void triggerValidationFailure() { - StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); + StandardServiceRegistryBuilder registryBuilder = applyConnectionProperties( new StandardServiceRegistryBuilder() ); registryBuilder.applySetting( HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, "none" ); ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) registryBuilder.build(); Metadata metadata = new MetadataSources( serviceRegistry ) @@ -53,6 +57,38 @@ public void triggerValidationFailure() { } } + private StandardServiceRegistryBuilder applyConnectionProperties(StandardServiceRegistryBuilder registryBuilder) { + // DB properties: + Map db = new HashMap<>(); + DatabaseContainer.configuration().add( db ); + registryBuilder.applySettings( db ); + // ES connection: + registryBuilder.applySetting( "hibernate.search.backend.uris", SearchBackendContainer.connectionUrl() ); + // Other settings: + + // # Hibernate ORM properties: + // ## Connection info: see above + registryBuilder.applySetting( "hibernate.hbm2ddl.auto", "create-drop" ); + registryBuilder.applySetting( "hibernate.show_sql", true ); + registryBuilder.applySetting( "hibernate.format_sql", true ); + registryBuilder.applySetting( "hibernate.max_fetch_depth", 5 ); + // We can't use classes from the hibernate-testing module unless we add an explicit dependency to that module. + // registryBuilder.applySetting( "hibernate.cache.region_prefix","hibernate.test"); + // registryBuilder.applySetting( "hibernate.cache.region.factory_class", "org.hibernate.testing.cache.CachingRegionFactory"); + + // # Hibernate Search properties: + // ## Connection info: see above + registryBuilder.applySetting( "hibernate.search.indexing.plan.synchronization.strategy", "sync" ); + registryBuilder.applySetting( "hibernate.search.backend.log.json_pretty_printing", "true" ); + registryBuilder.applySetting( + "hibernate.search.backend.analysis.configurer", + org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.config.MyElasticsearchAnalysisConfigurer.class + ); + + + return registryBuilder; + } + public void add(String name) { try ( Session session = sessionFactory.openSession() ) { session.getTransaction().begin(); diff --git a/integrationtest/java/modules/orm-elasticsearch/src/main/resources/hibernate.properties b/integrationtest/java/modules/orm-elasticsearch/src/main/resources/hibernate.properties deleted file mode 100644 index 952c912bc01..00000000000 --- a/integrationtest/java/modules/orm-elasticsearch/src/main/resources/hibernate.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Hibernate ORM properties: -## Connection info: see integration-test parent POM -hibernate.hbm2ddl.auto = create-drop -hibernate.show_sql = true -hibernate.format_sql = true -hibernate.max_fetch_depth = 5 -# We can't use classes from the hibernate-testing module unless we add an explicit dependency to that module. -#hibernate.cache.region_prefix hibernate.test -#hibernate.cache.region.factory_class = org.hibernate.testing.cache.CachingRegionFactory - -# Hibernate Search properties: -## Connection info: see POM -hibernate.search.indexing.plan.synchronization.strategy = sync -hibernate.search.backend.log.json_pretty_printing = true -hibernate.search.backend.analysis.configurer = org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.config.MyElasticsearchAnalysisConfigurer diff --git a/integrationtest/java/modules/orm-lucene/pom.xml b/integrationtest/java/modules/orm-lucene/pom.xml index 42099857889..157e4ef80d4 100644 --- a/integrationtest/java/modules/orm-lucene/pom.xml +++ b/integrationtest/java/modules/orm-lucene/pom.xml @@ -17,8 +17,6 @@ Hibernate Search integration tests for Java 11+ modules - false - 11 true @@ -34,6 +32,12 @@ hibernate-search-backend-lucene + + + org.hibernate.search + hibernate-search-util-internal-integrationtest-mapper-orm + + org.hibernate.search hibernate-search-util-internal-test-orm @@ -72,10 +76,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/java/modules/orm-lucene/src/main/java/module-info.java b/integrationtest/java/modules/orm-lucene/src/main/java/module-info.java index 8921d66f185..095e39ffc90 100644 --- a/integrationtest/java/modules/orm-lucene/src/main/java/module-info.java +++ b/integrationtest/java/modules/orm-lucene/src/main/java/module-info.java @@ -23,4 +23,7 @@ */ requires java.naming; + // Access to testcontainers: + requires hibernate.search.util.internal.integrationtest.mapper.orm; + } diff --git a/integrationtest/java/modules/orm-lucene/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/AuthorService.java b/integrationtest/java/modules/orm-lucene/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/AuthorService.java index 8573cd45cd5..70acbea7c52 100644 --- a/integrationtest/java/modules/orm-lucene/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/AuthorService.java +++ b/integrationtest/java/modules/orm-lucene/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/AuthorService.java @@ -6,7 +6,9 @@ */ package org.hibernate.search.integrationtest.java.modules.orm.lucene.service; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -18,6 +20,7 @@ import org.hibernate.search.integrationtest.java.modules.orm.lucene.entity.Author; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.service.spi.ServiceRegistryImplementor; public class AuthorService implements AutoCloseable { @@ -29,13 +32,41 @@ public AuthorService() { } private SessionFactory createSessionFactory() { - StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); + StandardServiceRegistryBuilder registryBuilder = applyConnectionProperties( new StandardServiceRegistryBuilder() ); ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) registryBuilder.build(); Metadata metadata = new MetadataSources( serviceRegistry ).addAnnotatedClass( Author.class ).buildMetadata(); SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder(); return sfb.build(); } + private StandardServiceRegistryBuilder applyConnectionProperties(StandardServiceRegistryBuilder registryBuilder) { + // DB properties: + Map db = new HashMap<>(); + DatabaseContainer.configuration().add( db ); + registryBuilder.applySettings( db ); + // Other settings: + + // # Hibernate ORM properties: + // ## Connection info: see above + registryBuilder.applySetting( "hibernate.hbm2ddl.auto", "create-drop" ); + registryBuilder.applySetting( "hibernate.show_sql", true ); + registryBuilder.applySetting( "hibernate.format_sql", true ); + registryBuilder.applySetting( "hibernate.max_fetch_depth", 5 ); + // We can't use classes from the hibernate-testing module unless we add an explicit dependency to that module. + // registryBuilder.applySetting( "hibernate.cache.region_prefix","hibernate.test"); + // registryBuilder.applySetting( "hibernate.cache.region.factory_class", "org.hibernate.testing.cache.CachingRegionFactory"); + + // # Hibernate Search properties: + // ## Connection info: see above + registryBuilder.applySetting( "hibernate.search.backend.type", "lucene" ); + registryBuilder.applySetting( "hibernate.search.indexing.plan.synchronization.strategy", "sync" ); + registryBuilder.applySetting( "hibernate.search.backend.directory.type", "local-heap" ); + registryBuilder.applySetting( "hibernate.search.backend.analysis.configurer", + org.hibernate.search.integrationtest.java.modules.orm.lucene.config.MyLuceneAnalysisConfigurer.class ); + + return registryBuilder; + } + public void add(String name) { try ( Session session = sessionFactory.openSession() ) { session.getTransaction().begin(); diff --git a/integrationtest/java/modules/orm-lucene/src/main/resources/hibernate.properties b/integrationtest/java/modules/orm-lucene/src/main/resources/hibernate.properties deleted file mode 100644 index 47b8be4e51c..00000000000 --- a/integrationtest/java/modules/orm-lucene/src/main/resources/hibernate.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Hibernate ORM properties: -## Connection info: see integration-test parent POM -hibernate.hbm2ddl.auto = create-drop -hibernate.show_sql = true -hibernate.format_sql = true -hibernate.max_fetch_depth = 5 -# We can't use classes from the hibernate-testing module unless we add an explicit dependency to that module. -#hibernate.cache.region_prefix hibernate.test -#hibernate.cache.region.factory_class = org.hibernate.testing.cache.CachingRegionFactory - -# Hibernate Search properties: -## Connection info: see POM -hibernate.search.backend.type=lucene -hibernate.search.indexing.plan.synchronization.strategy = sync -hibernate.search.backend.directory.type = local-heap -hibernate.search.backend.analysis.configurer = org.hibernate.search.integrationtest.java.modules.orm.lucene.config.MyLuceneAnalysisConfigurer diff --git a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/pom.xml b/integrationtest/java/modules/orm-outbox-polling-elasticsearch/pom.xml index feb1563d6da..8aa89e39d9b 100644 --- a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/pom.xml +++ b/integrationtest/java/modules/orm-outbox-polling-elasticsearch/pom.xml @@ -17,9 +17,6 @@ Hibernate Search integration tests for Java 11+ modules - ${test.elasticsearch.run.skip.forRelevantModules} - false - 11 true @@ -57,6 +54,16 @@ byte-buddy + + + org.hibernate.search + hibernate-search-util-internal-integrationtest-mapper-orm + + + org.hibernate.search + hibernate-search-util-internal-integrationtest-backend-elasticsearch + + org.hibernate.search hibernate-search-util-internal-test-orm @@ -95,10 +102,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/module-info.java b/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/module-info.java index 3d360ac9eab..f78b7973488 100644 --- a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/module-info.java +++ b/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/module-info.java @@ -16,6 +16,9 @@ requires org.hibernate.search.mapper.orm; requires org.hibernate.search.backend.elasticsearch; requires org.hibernate.search.mapper.orm.outboxpolling; + // Access to testcontainers: + requires hibernate.search.util.internal.integrationtest.mapper.orm; + requires hibernate.search.util.internal.integrationtest.backend.elasticsearch; /* * This is necessary in order to use SessionFactory, diff --git a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/outboxpolling/service/AuthorService.java b/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/outboxpolling/service/AuthorService.java index 3fd2646b3e7..56c9811b88f 100644 --- a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/outboxpolling/service/AuthorService.java +++ b/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/outboxpolling/service/AuthorService.java @@ -6,7 +6,9 @@ */ package org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.outboxpolling.service; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -21,6 +23,8 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.common.AssertionFailure; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.SearchBackendContainer; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.service.spi.ServiceRegistryImplementor; public class AuthorService implements AutoCloseable { @@ -32,7 +36,7 @@ public AuthorService() { } private SessionFactory createSessionFactory() { - StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); + StandardServiceRegistryBuilder registryBuilder = applyConnectionProperties( new StandardServiceRegistryBuilder() ); ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) registryBuilder.build(); Metadata metadata = new MetadataSources( serviceRegistry ).addAnnotatedClass( Author.class ).buildMetadata(); SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder(); @@ -40,7 +44,7 @@ private SessionFactory createSessionFactory() { } public void triggerValidationFailure() { - StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); + StandardServiceRegistryBuilder registryBuilder = applyConnectionProperties( new StandardServiceRegistryBuilder() ); registryBuilder.applySetting( HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, "none" ); ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) registryBuilder.build(); Metadata metadata = new MetadataSources( serviceRegistry ) @@ -53,6 +57,33 @@ public void triggerValidationFailure() { } } + private StandardServiceRegistryBuilder applyConnectionProperties(StandardServiceRegistryBuilder registryBuilder) { + // DB properties: + Map db = new HashMap<>(); + DatabaseContainer.configuration().add( db ); + registryBuilder.applySettings( db ); + // ES connection: + registryBuilder.applySetting( "hibernate.search.backend.uris", SearchBackendContainer.connectionUrl() ); + // # Hibernate ORM properties: + // ## Connection info: see above + registryBuilder.applySetting( "hibernate.hbm2ddl.auto", "create-drop" ); + registryBuilder.applySetting( "hibernate.show_sql", true ); + registryBuilder.applySetting( "hibernate.format_sql", true ); + registryBuilder.applySetting( "hibernate.max_fetch_depth", 5 ); + // We can't use classes from the hibernate-testing module unless we add an explicit dependency to that module. + // registryBuilder.applySetting( "hibernate.cache.region_prefix","hibernate.test"); + // registryBuilder.applySetting( "hibernate.cache.region.factory_class", "org.hibernate.testing.cache.CachingRegionFactory"); + + // # Hibernate Search properties: + // ## Connection info: see above + registryBuilder.applySetting( "hibernate.search.backend.log.json_pretty_printing", true ); + registryBuilder.applySetting( "hibernate.search.coordination.strategy", "outbox-polling" ); + registryBuilder.applySetting( "hibernate.search.backend.analysis.configurer", + org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.outboxpolling.config.MyElasticsearchAnalysisConfigurer.class ); + + return registryBuilder; + } + public void add(String name) { try ( Session session = sessionFactory.openSession() ) { session.getTransaction().begin(); diff --git a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/resources/hibernate.properties b/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/resources/hibernate.properties deleted file mode 100644 index 0bdd1605c5a..00000000000 --- a/integrationtest/java/modules/orm-outbox-polling-elasticsearch/src/main/resources/hibernate.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Hibernate ORM properties: -## Connection info: see integration-test parent POM -hibernate.hbm2ddl.auto = create-drop -hibernate.show_sql = true -hibernate.format_sql = true -hibernate.max_fetch_depth = 5 -# We can't use classes from the hibernate-testing module unless we add an explicit dependency to that module. -#hibernate.cache.region_prefix hibernate.test -#hibernate.cache.region.factory_class = org.hibernate.testing.cache.CachingRegionFactory - -# Hibernate Search properties: -## Connection info: see POM -hibernate.search.backend.log.json_pretty_printing = true -hibernate.search.coordination.strategy = outbox-polling -hibernate.search.backend.analysis.configurer = org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.outboxpolling.config.MyElasticsearchAnalysisConfigurer diff --git a/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml b/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml index e3af263297e..bb447f27d6c 100644 --- a/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml +++ b/integrationtest/java/modules/pojo-standalone-elasticsearch/pom.xml @@ -17,9 +17,6 @@ Hibernate Search integration tests for Java 11+ modules - ${test.elasticsearch.run.skip.forRelevantModules} - false - 11 true @@ -39,15 +36,15 @@ hibernate-search-backend-elasticsearch + org.hibernate.search - hibernate-search-util-internal-integrationtest-mapper-pojo-standalone - test + hibernate-search-util-internal-integrationtest-backend-elasticsearch org.hibernate.search - hibernate-search-util-internal-integrationtest-backend-elasticsearch + hibernate-search-util-internal-integrationtest-mapper-pojo-standalone test @@ -69,10 +66,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/module-info.java b/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/module-info.java index 6026feb1be2..478208ee8e6 100644 --- a/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/module-info.java +++ b/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/module-info.java @@ -8,4 +8,8 @@ requires org.hibernate.search.backend.elasticsearch; requires org.hibernate.search.mapper.pojo.standalone; + // Access to testcontainers: + requires hibernate.search.util.internal.integrationtest.backend.elasticsearch; + // Since testcontainers is using log4j we need to explicitly require it to make things work: + requires org.apache.logging.log4j; } diff --git a/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/AuthorService.java b/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/AuthorService.java index 5bdf33874f0..f03ae68fcc1 100644 --- a/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/AuthorService.java +++ b/integrationtest/java/modules/pojo-standalone-elasticsearch/src/main/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/AuthorService.java @@ -19,6 +19,7 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurer; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.SearchBackendContainer; public class AuthorService implements AutoCloseable { @@ -32,6 +33,7 @@ public AuthorService() { private CloseableSearchMapping createSearchMapping() { return SearchMapping.builder() + .property( "hibernate.search.backend.uris", SearchBackendContainer.connectionUrl() ) .property( "hibernate.search.backend.log.json_pretty_printing", true ) .property( "hibernate.search.backend.analysis.configurer", diff --git a/integrationtest/java/modules/pojo-standalone-lucene/pom.xml b/integrationtest/java/modules/pojo-standalone-lucene/pom.xml index dff13b01c0b..24568137d1b 100644 --- a/integrationtest/java/modules/pojo-standalone-lucene/pom.xml +++ b/integrationtest/java/modules/pojo-standalone-lucene/pom.xml @@ -17,8 +17,6 @@ Hibernate Search integration tests for Java 11+ modules - false - 11 true @@ -64,10 +62,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm-cdi/pom.xml b/integrationtest/mapper/orm-cdi/pom.xml index 6448c700cda..41a34ebd72e 100644 --- a/integrationtest/mapper/orm-cdi/pom.xml +++ b/integrationtest/mapper/orm-cdi/pom.xml @@ -68,11 +68,6 @@ - - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm-envers/pom.xml b/integrationtest/mapper/orm-envers/pom.xml index a7d59523da2..d4e7e7dfac4 100644 --- a/integrationtest/mapper/orm-envers/pom.xml +++ b/integrationtest/mapper/orm-envers/pom.xml @@ -12,10 +12,6 @@ Hibernate Search ITs - ORM - Envers Hibernate Search integration tests for the Hibernate ORM integration with Envers - - false - - org.hibernate.search @@ -58,11 +54,6 @@ - - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm-jakarta-batch/pom.xml b/integrationtest/mapper/orm-jakarta-batch/pom.xml index 14687a9729e..011cfa65296 100644 --- a/integrationtest/mapper/orm-jakarta-batch/pom.xml +++ b/integrationtest/mapper/orm-jakarta-batch/pom.xml @@ -13,9 +13,6 @@ Hibernate Search integration tests for the Jakarta Batch integration - ${test.elasticsearch.run.skip.forRelevantModules} - false - ${test.elasticsearch.connection.jvm.args} ${test.weld.jvm.args} @@ -173,11 +170,6 @@ - - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java index 04baeafbc50..aa88d7956a3 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java @@ -7,6 +7,7 @@ package org.hibernate.search.integrationtest.jakarta.batch.massindexing; import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.search.integrationtest.jakarta.batch.util.HibernateSearchBatchTestConnectionProperties.connectionProperties; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; import java.util.ArrayList; @@ -68,7 +69,7 @@ void setup() { whos.add( new WhoAmI( "cid03 " + index3, "id03 " + index3, "uid03 " + index3 ) ); } - emf = Persistence.createEntityManagerFactory( getPersistenceUnitName() ); + emf = Persistence.createEntityManagerFactory( getPersistenceUnitName(), connectionProperties() ); with( emf ).runInTransaction( em -> { companies.forEach( em::persist ); people.forEach( em::persist ); diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java index b34cc94d59f..5dd239eb050 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java @@ -126,8 +126,8 @@ void failureDuringNonFirstCheckpointBetweenTwoWrites_hql() throws InterruptedExc private void doTest(String reindexOnly, long expectedTotal, long expectedGoogle) throws InterruptedException { assertThat( JobTestUtil.nbDocumentsInIndex( emf, SimulatedFailureCompany.class ) ).isZero(); - List google = - JobTestUtil.findIndexedResults( emf, SimulatedFailureCompany.class, "name", "Google" ); + List google = JobTestUtil.findIndexedResults( + emf, SimulatedFailureCompany.class, "name", "Google" ); assertThat( google ).isEmpty(); // start the job diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/HibernateSearchBatchTestConnectionProperties.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/HibernateSearchBatchTestConnectionProperties.java new file mode 100644 index 00000000000..2489423bc90 --- /dev/null +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/HibernateSearchBatchTestConnectionProperties.java @@ -0,0 +1,34 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.integrationtest.jakarta.batch.util; + +import java.util.HashMap; +import java.util.Map; + +import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; +import org.hibernate.search.engine.cfg.BackendSettings; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.SearchBackendContainer; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; + +public final class HibernateSearchBatchTestConnectionProperties { + private HibernateSearchBatchTestConnectionProperties() { + } + + public static Map connectionProperties() { + Map properties = new HashMap<>(); + // if we run the ES version of the tests we have to set correct connection info based on testcontainer: + if ( "elasticsearch_pu".equals( PersistenceUnitTestUtil.getPersistenceUnitName() ) ) { + properties.put( + BackendSettings.backendKey( ElasticsearchBackendSettings.URIS ), + SearchBackendContainer.connectionUrl() + ); + } + DatabaseContainer.configuration().add( properties ); + + return properties; + } +} diff --git a/integrationtest/mapper/orm-outbox-polling/pom.xml b/integrationtest/mapper/orm-outbox-polling/pom.xml index 0e5d5b5b732..f8db81a30c9 100644 --- a/integrationtest/mapper/orm-outbox-polling/pom.xml +++ b/integrationtest/mapper/orm-outbox-polling/pom.xml @@ -14,8 +14,6 @@ coord-outbox - - false @@ -99,10 +97,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java b/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java index 9de0ad91bf7..824d514d5f8 100644 --- a/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java +++ b/integrationtest/mapper/orm-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java @@ -14,7 +14,11 @@ /** * Helper for running specific Hibernate ORM integration tests with outbox-polling from the IDE. *

- * Adapt the classpath filter as needed to run a single test or an entire test package. + * Adapt the {@code @IncludeClassNamePatterns}/{@code @SelectPackages} annotation as needed + * to run a single test or an entire test package. + *

+ * If tests against a non-H2 database are requested (e.g. with the ci-postgressql Maven profile), + * the database will be started automatically using TestContainers. */ @Suite @SuiteDisplayName("Outbox polling tests Runner") diff --git a/integrationtest/mapper/orm-realbackend/pom.xml b/integrationtest/mapper/orm-realbackend/pom.xml index 5cd28d45422..fb65dc1211c 100644 --- a/integrationtest/mapper/orm-realbackend/pom.xml +++ b/integrationtest/mapper/orm-realbackend/pom.xml @@ -13,9 +13,6 @@ Hibernate Search integration tests for the Hibernate ORM mapper with a real (non-mock) backend - ${test.elasticsearch.run.skip.forRelevantModules} - false - false @@ -138,10 +135,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml b/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml index 954a09748c7..04b67875966 100644 --- a/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml +++ b/integrationtest/mapper/orm-spring-uberjar/application/src/main/resources/application.yaml @@ -7,7 +7,7 @@ spring.jpa: directory.root: ${LUCENE_ROOT_PATH:target/test-indexes}/${random.uuid} spring.datasource: - driver-class: org.h2.Driver + driver-class-name: org.h2.Driver url: jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 username: sa password: sa \ No newline at end of file diff --git a/integrationtest/mapper/orm-spring/pom.xml b/integrationtest/mapper/orm-spring/pom.xml index cb43f641a58..540c7d39973 100644 --- a/integrationtest/mapper/orm-spring/pom.xml +++ b/integrationtest/mapper/orm-spring/pom.xml @@ -18,7 +18,7 @@ Remove Hibernate system properties from parent settings: They are supposed to be handled by the spring.datasource subsystem and not by the Hibernate internal pool! - See also the failsafe configuration. + See also the DatabaseContainer#springConfiguration(). --> @@ -89,20 +89,6 @@ maven-failsafe-plugin ${failsafe.spring.skip} - - - ${db.dialect} - ${jdbc.driver} - ${jdbc.url} - ${jdbc.user} - ${jdbc.pass} - ${jdbc.isolation} - @@ -114,10 +100,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java index ff9509f2ae0..7d255584a4a 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java @@ -26,6 +26,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.hibernate.search.util.impl.test.extension.StaticCounters; @@ -49,6 +50,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; import org.springframework.context.event.EventListener; +import org.springframework.mock.env.MockEnvironment; import org.springframework.stereotype.Component; /** @@ -177,8 +179,17 @@ private void doTest(ExpectedScope expectedScope, CounterKeys counterKeys, Be private ConfigurableApplicationContext startApplication() { Map properties = new LinkedHashMap<>(); properties.put( "test.backendMock", backendMock ); + + DatabaseContainer.Configuration configuration = DatabaseContainer.configuration(); + MockEnvironment environment = new MockEnvironment(); + environment.withProperty( "JDBC_DRIVER", configuration.driver() ); + environment.withProperty( "JDBC_URL", configuration.url() ); + environment.withProperty( "JDBC_USERNAME", configuration.user() ); + environment.withProperty( "JDBC_PASSWORD", configuration.pass() ); + return new SpringApplicationBuilder( SpringConfig.class ) .web( WebApplicationType.NONE ) + .environment( environment ) .properties( properties ) .run(); } diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java index bb05ec606eb..d26d799e535 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java @@ -14,6 +14,7 @@ import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder; import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.hibernate.search.mapper.orm.session.impl.HibernateOrmSearchSessionHolder; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; @@ -21,21 +22,18 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringApplicationConfiguration.class) @ActiveProfiles("jta") @PortedFromSearch5(original = "org.hibernate.search.test.integration.spring.jta.JtaAndSpringIT") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class JtaAndSpringIT { +class JtaAndSpringIT extends AbstractMapperOrmSpringIT { @Autowired @RegisterExtension diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java index 8d9dbc02d17..4587e8cdd0c 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java @@ -16,6 +16,7 @@ import org.hibernate.search.integrationtest.spring.jta.entity.Box; import org.hibernate.search.integrationtest.spring.jta.entity.Doughnut; import org.hibernate.search.integrationtest.spring.jta.entity.Muffin; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.hibernate.search.mapper.orm.session.impl.HibernateOrmSearchSessionHolder; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; @@ -23,21 +24,18 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringApplicationConfiguration.class) @ActiveProfiles("jta") @PortedFromSearch5(original = "org.hibernate.search.test.integration.spring.jta.JtaAndSpringMoreComplexIT") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class JtaAndSpringMoreComplexIT { +class JtaAndSpringMoreComplexIT extends AbstractMapperOrmSpringIT { @Autowired @RegisterExtension diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java index aaea9a49a62..793cd52159b 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java @@ -14,26 +14,24 @@ import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder; import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.hibernate.search.mapper.orm.session.impl.HibernateOrmSearchSessionHolder; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringOutboxApplicationConfiguration.class) @ActiveProfiles({ "jta", "outbox" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class JtaAndSpringOutboxIT { +class JtaAndSpringOutboxIT extends AbstractMapperOrmSpringIT { @Autowired @RegisterExtension diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java index 282f78d88f1..1844f31fc13 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java @@ -15,11 +15,11 @@ import org.hibernate.search.integrationtest.spring.jta.JtaAndSpringOutboxApplicationConfiguration; import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; import com.atomikos.icatch.jta.TransactionManagerImp; @@ -28,13 +28,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringOutboxApplicationConfiguration.class) @ActiveProfiles({ "jta", "outbox", "transaction-timeout", "raised-timeout" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class RaisedTimeoutJtaAndSpringOutboxIT { +class RaisedTimeoutJtaAndSpringOutboxIT extends AbstractMapperOrmSpringIT { @Autowired @RegisterExtension diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java index 6cf108d92f5..98be0769737 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java @@ -16,10 +16,10 @@ import org.hibernate.search.integrationtest.spring.jta.JtaAndSpringOutboxApplicationConfiguration; import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import com.atomikos.icatch.jta.TransactionManagerImp; @@ -27,13 +27,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringOutboxApplicationConfiguration.class) @ActiveProfiles({ "jta", "outbox", "transaction-timeout" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class TransactionTimeoutJtaAndSpringOutboxIT { +class TransactionTimeoutJtaAndSpringOutboxIT extends AbstractMapperOrmSpringIT { @Autowired private SnertDAO snertDAO; @@ -56,7 +54,7 @@ void checkJta() { } @Test - void test() throws Exception { + void test() { Snert snert = new Snert(); snert.setId( 1L ); snert.setName( "dave" ); diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java index c0f13003e4b..b18b3016d0e 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java @@ -10,32 +10,28 @@ import jakarta.persistence.EntityManager; import jakarta.persistence.Id; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.hibernate.search.integrationtest.spring.testsupport.AbstractSpringITConfig; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Service; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -@ExtendWith(SpringExtension.class) -@SpringBootTest @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @ActiveProfiles(profiles = { "outbox" }) -class TransactionOutboxIT { +class TransactionOutboxIT extends AbstractMapperOrmSpringIT { @Configuration @EntityScan diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java index e7b627d4b0f..03daa770531 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java @@ -18,6 +18,7 @@ import jakarta.persistence.EntityManager; import jakarta.persistence.Id; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.hibernate.search.integrationtest.spring.testsupport.AbstractSpringITConfig; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; @@ -29,17 +30,14 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Service; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.support.TransactionTemplate; @@ -48,10 +46,8 @@ * one can create a single SearchSession for all threads, and it will correctly use the correct EntityManager * depending on the current thread. */ -@ExtendWith(SpringExtension.class) -@SpringBootTest @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -class SessionProxyIT { +class SessionProxyIT extends AbstractMapperOrmSpringIT { @Configuration @EntityScan diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractMapperOrmSpringIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractMapperOrmSpringIT.java new file mode 100644 index 00000000000..9a68b64846e --- /dev/null +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractMapperOrmSpringIT.java @@ -0,0 +1,21 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.integrationtest.spring.testsupport; + +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; + +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; + +@SpringBootTest +public abstract class AbstractMapperOrmSpringIT { + @DynamicPropertySource + static void configureProperties(DynamicPropertyRegistry registry) { + DatabaseContainer.configuration().addAsSpring( (key, value) -> registry.add( key, () -> value ) ); + } +} diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java index eedf18fb581..1f9242eaff3 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java @@ -10,13 +10,13 @@ import jakarta.persistence.EntityManager; import jakarta.persistence.Id; +import org.hibernate.search.integrationtest.spring.testsupport.AbstractMapperOrmSpringIT; import org.hibernate.search.integrationtest.spring.testsupport.AbstractSpringITConfig; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; @@ -27,16 +27,14 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -@ExtendWith(SpringExtension.class) // Adding a property here is just a "workaround" to make sure that a different context is used for this test // otherwise there can be build errors when running all the tests via maven. @SpringBootTest(properties = "spring.jta.atomikos.datasource.bean-name=hsearch-datasource1") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) -class TransactionIT { +class TransactionIT extends AbstractMapperOrmSpringIT { @Configuration @EntityScan diff --git a/integrationtest/mapper/orm-spring/src/test/resources/application.yaml b/integrationtest/mapper/orm-spring/src/test/resources/application.yaml index bd5c916a670..6a9ff30ff7d 100644 --- a/integrationtest/mapper/orm-spring/src/test/resources/application.yaml +++ b/integrationtest/mapper/orm-spring/src/test/resources/application.yaml @@ -2,14 +2,12 @@ spring.jpa: hibernate: ddl-auto: create-drop properties: - hibernate: - dialect: ${HIBERNATE_DIALECT} # From environment variable hibernate.search: # The backend is a mock anyway. schema_management.strategy: none spring.datasource: - driver-class: ${JDBC_DRIVER} # From environment variable + driver-class-name: ${JDBC_DRIVER} # From environment variable url: ${JDBC_URL} # From environment variable username: ${JDBC_USERNAME} # From environment variable password: ${JDBC_PASSWORD} # From environment variable @@ -22,10 +20,6 @@ logging.level: org.hibernate.search.elasticsearch.request: DEBUG org.hibernate.search.backend.lucene: DEBUG -# Default environment variable values for IDEs that are unable to extract them from the maven-failsafe configuration -# These values are overridden when running tests from Intellij IDEA or directly from Maven -JDBC_URL: jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 - # since atomikos connection pool has a max size set to 1 ... # we will not be able to execute more than one transaction at a time, leading to errors in tests spring: diff --git a/integrationtest/mapper/orm/pom.xml b/integrationtest/mapper/orm/pom.xml index 5f137c99b5a..9a60b6d52ba 100644 --- a/integrationtest/mapper/orm/pom.xml +++ b/integrationtest/mapper/orm/pom.xml @@ -12,10 +12,6 @@ Hibernate Search ITs - ORM Hibernate Search integration tests for the Hibernate ORM integration - - false - - org.hibernate.search @@ -65,11 +61,6 @@ - - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java index 7b8398722c3..5c96b8608b7 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java @@ -13,6 +13,7 @@ import java.lang.reflect.Field; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -44,6 +45,7 @@ import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleSessionFactoryBuilder; @@ -116,6 +118,7 @@ public void configure(HibernateOrmMappingConfigurationContext context) { } } ); + DatabaseContainer.configuration().add( booterGeneratedProperties ); for ( Map.Entry booterGeneratedProperty : booterGeneratedProperties.entrySet() ) { builder.setProperty( booterGeneratedProperty.getKey(), booterGeneratedProperty.getValue() ); } @@ -160,6 +163,9 @@ private HibernateOrmIntegrationBooter createBooter(CompletableFuture connectionProperties = new HashMap<>(); + DatabaseContainer.configuration().add( connectionProperties ); + registryBuilder.applySettings( connectionProperties ); StandardServiceRegistry serviceRegistry = registryBuilder.build(); toClose.add( serviceRegistry ); diff --git a/integrationtest/mapper/pojo-standalone-realbackend/pom.xml b/integrationtest/mapper/pojo-standalone-realbackend/pom.xml index 48963149289..aeb04a0d3cd 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/pom.xml +++ b/integrationtest/mapper/pojo-standalone-realbackend/pom.xml @@ -12,10 +12,6 @@ Hibernate Search ITs - POJO Standalone - Real backend Hibernate Search integration tests for the POJO Standalone mapper with a real (non-mock) backend - - ${test.elasticsearch.run.skip.forRelevantModules} - - org.hibernate.search @@ -103,10 +99,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/performance/backend/elasticsearch/pom.xml b/integrationtest/performance/backend/elasticsearch/pom.xml index 0b150dbcef0..6192de56afe 100644 --- a/integrationtest/performance/backend/elasticsearch/pom.xml +++ b/integrationtest/performance/backend/elasticsearch/pom.xml @@ -21,8 +21,6 @@ true - - ${test.elasticsearch.run.skip.forRelevantModules} @@ -65,10 +63,6 @@ - - io.fabric8 - docker-maven-plugin - org.bsc.maven maven-processor-plugin diff --git a/integrationtest/showcase/library/pom.xml b/integrationtest/showcase/library/pom.xml index 4739a2f9d3a..34df729b427 100644 --- a/integrationtest/showcase/library/pom.xml +++ b/integrationtest/showcase/library/pom.xml @@ -13,9 +13,6 @@ Hibernate Search showcase based on the ORM and Elasticsearch integrations, using libraries and books as business objects - ${test.elasticsearch.run.skip.forRelevantModules} - false - ${failsafe.spring.skip} ${failsafe.spring.skip} @@ -49,6 +46,12 @@ hibernate-search-backend-elasticsearch-aws test + + + org.hibernate.search + hibernate-search-util-internal-integrationtest-backend-elasticsearch + test + org.springframework.boot @@ -117,12 +120,6 @@ Here we chose to use environment variables. --> - ${db.dialect} - ${jdbc.driver} - ${jdbc.url} - ${jdbc.user} - ${jdbc.pass} - ${jdbc.isolation} ${test.elasticsearch.connection.uris} ${test.elasticsearch.connection.username} ${test.elasticsearch.connection.password} @@ -178,10 +175,6 @@ - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/showcase/library/src/main/resources/application.yaml b/integrationtest/showcase/library/src/main/resources/application.yaml index 64ac5327dc5..1b64af49a8d 100644 --- a/integrationtest/showcase/library/src/main/resources/application.yaml +++ b/integrationtest/showcase/library/src/main/resources/application.yaml @@ -1,10 +1,5 @@ -spring.jpa: - properties: - hibernate: - dialect: ${HIBERNATE_DIALECT} # From environment variable - spring.datasource: - driver-class: ${JDBC_DRIVER} # From environment variable + driver-class-name: ${JDBC_DRIVER} # From environment variable url: ${JDBC_URL} # From environment variable username: ${JDBC_USERNAME} # From environment variable password: ${JDBC_PASSWORD} # From environment variable diff --git a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/AbstractLibraryShowcaseSearchIT.java b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/AbstractLibraryShowcaseSearchIT.java new file mode 100644 index 00000000000..b4637d0d24f --- /dev/null +++ b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/AbstractLibraryShowcaseSearchIT.java @@ -0,0 +1,28 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.integrationtest.showcase.library; + +import static org.hibernate.search.integrationtest.showcase.library.TestActiveProfilesResolver.configuredBackend; + +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.SearchBackendContainer; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; + +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; + +@SpringBootTest +abstract class AbstractLibraryShowcaseSearchIT { + @DynamicPropertySource + static void configureProperties(DynamicPropertyRegistry registry) { + DatabaseContainer.configuration().addAsSpring( (key, value) -> registry.add( key, () -> value ) ); + + if ( "elasticsearch".equals( configuredBackend() ) ) { + registry.add( "spring.jpa.properties.hibernate.search.backend.uris", SearchBackendContainer::connectionUrl ); + } + } +} diff --git a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java index a1801f14bd2..49ce4fdbb6e 100644 --- a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java +++ b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java @@ -19,16 +19,14 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; -@SpringBootTest @TestPropertySource(properties = { "spring.jpa.properties.hibernate.search.indexing.listeners.enabled=false" }) @ActiveProfiles(resolver = TestActiveProfilesResolver.class) -class LibraryShowcaseMassIndexingIT { +class LibraryShowcaseMassIndexingIT extends AbstractLibraryShowcaseSearchIT { private static final int NUMBER_OF_BOOKS = 200; diff --git a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java index 65139a73ae5..3755120498a 100644 --- a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java +++ b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java @@ -58,14 +58,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -@SpringBootTest @ActiveProfiles(resolver = TestActiveProfilesResolver.class) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -class LibraryShowcaseSearchIT { +class LibraryShowcaseSearchIT extends AbstractLibraryShowcaseSearchIT { private static boolean needsInit; diff --git a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/TestActiveProfilesResolver.java b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/TestActiveProfilesResolver.java index e1c3b826785..af4d47e7dfc 100644 --- a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/TestActiveProfilesResolver.java +++ b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/TestActiveProfilesResolver.java @@ -9,20 +9,24 @@ import org.springframework.test.context.ActiveProfilesResolver; public class TestActiveProfilesResolver implements ActiveProfilesResolver { + + /* + * Default when running tests from within an IDE. + * This is the main reason we're using an ActiveProfilesResolver: + * there is apparently no way to set default profiles for tests, + * as setting "spring.profiles.active" in a @TestPropertySource for example + * will *override* any command-line arguments, environment properties or system properties. + */ + private static final String DEFAULT_BACKEND = "lucene"; + @Override public String[] resolve(Class testClass) { - String testBackend = System.getProperty( "test.backend" ); - if ( testBackend == null ) { - /* - * Default when running tests from within an IDE. - * This is the main reason we're using an ActiveProfilesResolver: - * there is apparently no way to set default profiles for tests, - * as setting "spring.profiles.active" in a @TestPropertySource for example - * will *override* any command-line arguments, environment properties or system properties. - */ - testBackend = "lucene"; - } + String testBackend = configuredBackend(); // The test profiles must be mentioned last, to allow them to override properties return new String[] { testBackend, "test", "test-" + testBackend }; } + + public static String configuredBackend() { + return System.getProperty( "test.backend", DEFAULT_BACKEND ); + } } diff --git a/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java b/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java index d801f9d55f5..e2a8d6596c5 100644 --- a/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java +++ b/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java @@ -29,10 +29,9 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -@SpringBootTest @ActiveProfiles(resolver = TestActiveProfilesResolver.class) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -class Java17IT { +class Java17IT extends AbstractLibraryShowcaseSearchIT{ private static boolean needsInit; diff --git a/integrationtest/showcase/library/src/test/resources/application-test-elasticsearch.yaml b/integrationtest/showcase/library/src/test/resources/application-test-elasticsearch.yaml index 856005b0e97..ea4b07f5d18 100644 --- a/integrationtest/showcase/library/src/test/resources/application-test-elasticsearch.yaml +++ b/integrationtest/showcase/library/src/test/resources/application-test-elasticsearch.yaml @@ -3,3 +3,4 @@ spring.jpa: hibernate.search: backend: log.json_pretty_printing: true + uris: ${ELASTICSEARCH_URIS:localhost:9200} diff --git a/integrationtest/showcase/library/src/test/resources/application-test.yaml b/integrationtest/showcase/library/src/test/resources/application-test.yaml index 9b389e11a6b..aac79e7aaf9 100644 --- a/integrationtest/showcase/library/src/test/resources/application-test.yaml +++ b/integrationtest/showcase/library/src/test/resources/application-test.yaml @@ -17,7 +17,3 @@ logging.level: org.hibernate.search.query: DEBUG org.hibernate.search.elasticsearch.request: DEBUG org.hibernate.search.backend.lucene: DEBUG - -# Default environment variable values for IDEs that are unable to extract them from the maven-failsafe configuration -# These values are overridden when running tests from Intellij IDEA or directly from Maven -JDBC_URL: jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 diff --git a/integrationtest/v5migrationhelper/orm/pom.xml b/integrationtest/v5migrationhelper/orm/pom.xml index a2cef0402d2..93d0a086f72 100755 --- a/integrationtest/v5migrationhelper/orm/pom.xml +++ b/integrationtest/v5migrationhelper/orm/pom.xml @@ -108,11 +108,6 @@ - - - io.fabric8 - docker-maven-plugin - diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/batchindexing/DatabaseMultitenancyTest.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/batchindexing/DatabaseMultitenancyTest.java index 5abbc08a6c3..51f677d8121 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/batchindexing/DatabaseMultitenancyTest.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/batchindexing/DatabaseMultitenancyTest.java @@ -8,6 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.listAll; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.IOException; import java.util.List; @@ -20,8 +21,7 @@ import org.hibernate.search.query.dsl.QueryBuilder; import org.hibernate.search.test.SearchTestBase; import org.hibernate.search.util.common.impl.CollectionHelper; - -import org.hibernate.testing.orm.junit.RequiresDialect; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -43,10 +43,6 @@ * @author Sanne Grinovero * @since 5.2 */ -@RequiresDialect( - comment = "The connection provider for this test ignores configuration and requires H2", - value = org.hibernate.dialect.H2Dialect.class -) class DatabaseMultitenancyTest extends SearchTestBase { /** @@ -74,6 +70,7 @@ class DatabaseMultitenancyTest extends SearchTestBase { @Override @BeforeEach public void setUp() throws Exception { + requiresDialectCheck(); super.setUp(); Session sessionMetamec = openSessionWithTenantId( METAMEC_TID ); @@ -224,6 +221,7 @@ private void persist(Session session, Object... clocks) { @AfterEach void deleteEntities() { + requiresDialectCheck(); Session session = openSessionWithTenantId( METAMEC_TID ); deleteClocks( session ); session.close(); @@ -233,6 +231,13 @@ void deleteEntities() { session.close(); } + private static void requiresDialectCheck() { + assumeTrue( + org.hibernate.dialect.H2Dialect.class.getName().equals( DatabaseContainer.configuration().driver() ), + "The connection provider for this test ignores configuration and requires H2" + ); + } + private void deleteClocks(Session session) { session.beginTransaction(); List clocks = listAll( session, Clock.class ); diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java index f65309f0d83..69008ee2302 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java @@ -9,8 +9,12 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.util.HashMap; +import java.util.Map; + import org.hibernate.cfg.Configuration; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.junit.jupiter.api.Test; @@ -23,6 +27,13 @@ class UnresolvedBridgeTest { void testSerializableType() { Configuration cfg = new Configuration(); + // DB properties: + Map db = new HashMap<>(); + DatabaseContainer.configuration().add( db ); + for ( Map.Entry entry : db.entrySet() ) { + cfg.setProperty( entry.getKey(), entry.getValue().toString() ); + } + for ( int i = 0; i < getAnnotatedClasses().length; i++ ) { cfg.addAnnotatedClass( getAnnotatedClasses()[i] ); } diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/configuration/LobTest.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/configuration/LobTest.java index f195aa6b854..9ed5c7e7c54 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/configuration/LobTest.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/configuration/LobTest.java @@ -7,6 +7,7 @@ package org.hibernate.search.test.configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.util.List; @@ -17,7 +18,6 @@ import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.dialect.SybaseDialect; import org.hibernate.search.FullTextQuery; import org.hibernate.search.FullTextSession; import org.hibernate.search.Search; @@ -26,8 +26,7 @@ import org.hibernate.search.query.dsl.QueryBuilder; import org.hibernate.search.test.SearchTestBase; import org.hibernate.search.testsupport.TestForIssue; - -import org.hibernate.testing.orm.junit.SkipForDialect; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.junit.jupiter.api.Test; @@ -42,8 +41,11 @@ class LobTest extends SearchTestBase { @Test - @SkipForDialect(dialectClass = SybaseDialect.class, reason = "Sybase does not support @Lob") void testCreateIndexSearchEntityWithLobField() { + assumeFalse( + org.hibernate.dialect.SybaseDialect.class.getName().equals( DatabaseContainer.configuration().driver() ), + "Sybase does not support @Lob" + ); // create and index Session session = openSession(); Transaction tx = session.beginTransaction(); diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/envers/SearchAndEnversIntegrationTest.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/envers/SearchAndEnversIntegrationTest.java index b795cf5e439..0f8fae8a65e 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/envers/SearchAndEnversIntegrationTest.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/envers/SearchAndEnversIntegrationTest.java @@ -7,11 +7,11 @@ package org.hibernate.search.test.envers; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.util.List; import org.hibernate.Transaction; -import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.envers.AuditReader; import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.query.AuditEntity; @@ -21,8 +21,7 @@ import org.hibernate.search.test.SearchTestBase; import org.hibernate.search.testsupport.TestForIssue; import org.hibernate.search.testsupport.junit.Tags; - -import org.hibernate.testing.orm.junit.SkipForDialect; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -37,7 +36,6 @@ * * @author Davide Di Somma */ -@SkipForDialect(reason = "HSEARCH-1943", dialectClass = PostgreSQLDialect.class) @Tag(Tags.PORTED_TO_SEARCH_6) class SearchAndEnversIntegrationTest extends SearchTestBase { @@ -53,6 +51,10 @@ class SearchAndEnversIntegrationTest extends SearchTestBase { @TestForIssue(jiraKey = "HSEARCH-1293") @Test void testHibernateSearchAndEnversIntegration() { + assumeFalse( + org.hibernate.dialect.PostgreSQLDialect.class.getName().equals( DatabaseContainer.configuration().driver() ), + "HSEARCH-1943" + ); atRevision1(); atRevision2(); atRevision3(); diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java index 7e516ba370a..fd13d4186e5 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java @@ -23,6 +23,7 @@ import org.hibernate.search.util.impl.integrationtest.common.extension.BackendSetupStrategy; import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmAssertionHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; @@ -104,6 +105,8 @@ public final class SetupContext // Ensure we don't build Jandex indexes needlessly: // discovery based on Jandex ought to be tested in real projects that don't use this setup helper. withProperty( HibernateOrmMapperSettings.MAPPING_BUILD_MISSING_DISCOVERED_JANDEX_INDEXES, false ); + // DB properties: + DatabaseContainer.configuration().add( overriddenProperties ); // Ensure overridden properties will be applied withConfiguration( builder -> overriddenProperties.forEach( builder::setProperty ) ); } diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperOrmSetupHelper.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperOrmSetupHelper.java index a90f42032e5..7dd0a3fd7be 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperOrmSetupHelper.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperOrmSetupHelper.java @@ -23,6 +23,7 @@ import org.hibernate.search.util.impl.integrationtest.common.extension.BackendSetupStrategy; import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.DatabaseContainer; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmAssertionHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; @@ -105,6 +106,10 @@ public final class SetupContext // Ensure we don't build Jandex indexes needlessly: // discovery based on Jandex ought to be tested in real projects that don't use this setup helper. withProperty( HibernateOrmMapperSettings.MAPPING_BUILD_MISSING_DISCOVERED_JANDEX_INDEXES, false ); + + // DB properties: + DatabaseContainer.configuration().add( overriddenProperties ); + // Ensure overridden properties will be applied withConfiguration( builder -> overriddenProperties.forEach( builder::setProperty ) ); } diff --git a/pom.xml b/pom.xml index 74f834901fb..3759e05f8f5 100644 --- a/pom.xml +++ b/pom.xml @@ -291,7 +291,6 @@ 9.6 0.8.11 2.0.8 - 0.43.4 1.1.0 3.10.0.2594 3.0.0 @@ -378,53 +377,14 @@ 8.10.4 - ${version.org.elasticsearch.latest} - - true - docker.io/elastic/elasticsearch - ${test.elasticsearch.version} - - true - docker.io/opensearchproject/opensearch - ${test.elasticsearch.version} - - - true - - - true - docker.io/postgres - 15.1 - - - true - docker.io/mariadb - 10.10.2 - - - true - docker.io/mysql - 8.0.31 - - - true - docker.io/ibmcom/db2 - 11.5.8.0 - - - true - docker.io/gvenzl/oracle-xe - 21.3.0-slim-faststart - - - true - mcr.microsoft.com/mssql/server - 2019-CU18-ubuntu-20.04 - - - true - docker.io/cockroachdb/cockroach - v23.1.4 + + elastic + + + h2 + + true @@ -927,11 +887,6 @@ - - io.fabric8 - docker-maven-plugin - ${version.docker.maven.plugin} - org.jacoco jacoco-maven-plugin @@ -986,33 +941,30 @@ -->