diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64efadc8873..76d77208567 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,8 @@ 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, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 61dbb1cb87e..dbc264a8ed7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -397,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 175a1b2bef4..6149984862f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -431,6 +431,7 @@ stage('Default build') { ${commonMavenArgs} \ -DskipSurefireTests \ -Pskip-checks \ + -Pci-build \ -Pci-rebuild \ ${incrementalBuild ? """ \ -Dincremental \ @@ -938,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/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/parents/build/pom.xml b/build/parents/build/pom.xml index b9d9702cc57..9959ac2cb25 100644 --- a/build/parents/build/pom.xml +++ b/build/parents/build/pom.xml @@ -1188,6 +1188,17 @@ org.apache.maven.plugins maven-failsafe-plugin + + + docker.io/testcontainers/ryuk:0.5.1 + + true + ${project.version} ${test.performance.enable} @@ -1311,6 +1322,25 @@ + + ci-build + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + true + + + + + + + dependency-update 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/pom.xml b/pom.xml index 5dfa8f7cbc8..3dc35a33c9c 100644 --- a/pom.xml +++ b/pom.xml @@ -953,13 +953,19 @@ def images = [] def isTrueString = { string -> string && Boolean.parseBoolean( string ) } def isNotBlankString = { string -> string?.trim() } + def parseImage = { file -> + { + def dockerFileContent = new File(file).text + if ((match = dockerFileContent =~ /FROM (.+)/)) { + return match.group(1).trim() + } + return '' + } + } + images += parseImage( './build/container/ryuk.Dockerfile' ) if ( isNotBlankString( '${test.database.run.kind}' ) && '${test.database.run.kind}' != 'h2') { - def dockerFileContent = new File('./build/container/${test.database.run.kind}.Dockerfile').text - if ((match = dockerFileContent =~ /FROM (.+)/)) { - def image = match.group(1).trim() - images += image - } + images += parseImage( './build/container/${test.database.run.kind}.Dockerfile' ) } if ( isTrueString( '${test.elasticsearch.run.image.pull}' ) && isNotBlankString( '${test.elasticsearch.run.image.name}' ) ) { images += '${test.elasticsearch.run.image.name}:${test.elasticsearch.run.image.tag}'