UNOMI-921: Replace elasticsearch-maven-plugin with Docker-based Elasticsearch in integration tests#767
Merged
Merged
Conversation
…icsearch in integration tests Implements the core configuration switch from UNOMI-921: https://issues.apache.org/jira/browse/UNOMI-921 Replace the com.github.alexcojocaru:elasticsearch-maven-plugin (binary download + forked JVM) with io.fabric8:docker-maven-plugin in the elasticsearch profile of itests, mirroring how the opensearch profile already runs OpenSearch in a Docker container. itests/pom.xml (elasticsearch profile) * Add an <elasticsearch.port>9400</elasticsearch.port> property and pass it through the failsafe systemPropertyVariables so tests resolve the HTTP port from a single source (unchanged from the previous 9400). * Replace the elasticsearch-maven-plugin block with a docker-maven-plugin block that runs docker.elastic.co/elasticsearch/elasticsearch:${elasticsearch.test.version}, binds target/snapshots_repository to /tmp/snapshots_repository, and waits on the HTTP port before the integration-test phase. Heap aligned to 8GB (-Xms8g -Xmx8g) to match the OpenSearch configuration and the ES 9 recommendation. Discovery=single-node, replicas=0, xpack.ml and xpack.security disabled. * Container lifecycle matches OpenSearch exactly: pre-integration-test runs stop+remove then start (with showLogs); post-integration-test runs stop only -- container is kept around for inspection. * Add a chmod -R ugo+rwx on snapshots_repository in the antrun unzip step: the ES container runs as UID 1000, so on Linux CI the bind-mounted snapshot repo otherwise hits access_denied during repository verify. pom.xml (root) * Declare <docker-maven-plugin.version>0.48.0</docker-maven-plugin.version> and add the pluginManagement entry so the elasticsearch profile (and any future user of the plugin) inherits a single version. Scope kept minimal for the PR #757 stack split: only the test infrastructure switch lives here. The follow-up UNOMI-921 acceptance items below ship in the platform PR (P) once it lands: * Remove BaseIT.fixDefaultTemplateIfNeeded() and the call in checkSearchEngine() (no longer needed with Docker). * Migrate16xToCurrentVersionIT: replace hardcoded ES_BASE_URL = "http://localhost:9400" with dynamic getSearchPort(). * Drop the comments referring to the elasticsearch-maven-plugin template-override workaround. See docs/PR-757-stack-extraction-tracker.md for the full split plan and how this PR fits in the stack.
Non-interactive prompts when CI, GITHUB_ACTIONS, or BUILD_NON_INTERACTIVE is set. Add --ci (no Karaf, no Maven build cache) and MAVEN_EXTRA_OPTS for matrix ports.
Replace fixed sleeps in GraphQLListIT and poll after patch refresh in PatchIT.
Poll profile properties after events in PropertiesUpdateActionIT.
Align CI with local developer workflow; pass matrix ports via MAVEN_EXTRA_OPTS.
…icsearch in integration tests Implements the core configuration switch from UNOMI-921: https://issues.apache.org/jira/browse/UNOMI-921 Replace the com.github.alexcojocaru:elasticsearch-maven-plugin (binary download + forked JVM) with io.fabric8:docker-maven-plugin in the elasticsearch profile of itests, mirroring how the opensearch profile already runs OpenSearch in a Docker container. itests/pom.xml (elasticsearch profile) * Add an <elasticsearch.port>9400</elasticsearch.port> property and pass it through the failsafe systemPropertyVariables so tests resolve the HTTP port from a single source (unchanged from the previous 9400). * Replace the elasticsearch-maven-plugin block with a docker-maven-plugin block that runs docker.elastic.co/elasticsearch/elasticsearch:${elasticsearch.test.version}, binds target/snapshots_repository to /tmp/snapshots_repository, and waits on the HTTP port before the integration-test phase. Heap aligned to 8GB (-Xms8g -Xmx8g) to match the OpenSearch configuration and the ES 9 recommendation. Discovery=single-node, replicas=0, xpack.ml and xpack.security disabled. * Container lifecycle matches OpenSearch exactly: pre-integration-test runs stop+remove then start (with showLogs); post-integration-test runs stop only -- container is kept around for inspection. * Add a chmod -R ugo+rwx on snapshots_repository in the antrun unzip step: the ES container runs as UID 1000, so on Linux CI the bind-mounted snapshot repo otherwise hits access_denied during repository verify. pom.xml (root) * Declare <docker-maven-plugin.version>0.48.0</docker-maven-plugin.version> and add the pluginManagement entry so the elasticsearch profile (and any future user of the plugin) inherits a single version. Scope kept minimal for the PR #757 stack split: only the test infrastructure switch lives here. The follow-up UNOMI-921 acceptance items below ship in the platform PR (P) once it lands: * Remove BaseIT.fixDefaultTemplateIfNeeded() and the call in checkSearchEngine() (no longer needed with Docker). * Migrate16xToCurrentVersionIT: replace hardcoded ES_BASE_URL = "http://localhost:9400" with dynamic getSearchPort(). * Drop the comments referring to the elasticsearch-maven-plugin template-override workaround. See docs/PR-757-stack-extraction-tracker.md for the full split plan and how this PR fits in the stack.
…MI-921-itests-es-docker
# Conflicts: # build.sh # itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java # itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLListIT.java
- Make ES heap configurable via ${elasticsearch.heap} (default 4g, aligns with OpenSearch)
- Remove -Dcluster.default.index.settings.number_of_replicas=0 from JAVA_OPTS
(was a JVM property, not an ES/OS setting — had no effect)
- Add it.keepContainer Maven property + --keep-container flag in build.sh
to keep the search engine container alive after tests for inspection
- Add missing stop-opensearch post-integration-test execution (symmetry with ES)
- Add ignoreRunningContainers to both pre-start cleanup executions
- Restore GraphQLListIT catch block and null-guard for polling resilience
- PropertiesUpdateActionIT: keep in-memory assertion for current-profile path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PR (merge order)
masterUNOMI-921-itests-es-dockerThis PR is stacked: it is the bottom of a chain. Merge into
masterfirst; downstream branches that build on top will resync onto the newmastertip.JIRA: https://issues.apache.org/jira/browse/UNOMI-921 — Replace elasticsearch-maven-plugin with Docker-based Elasticsearch Instance in integration tests.
Why this change
The
elasticsearchprofile initests/pom.xmlcurrently usescom.github.alexcojocaru:elasticsearch-maven-pluginto download an Elasticsearch tarball and run it as a forked JVM during the Maven build. This approach:default_templatethat overrides user templates on ES 8/9 — currently worked around byBaseIT.fixDefaultTemplateIfNeeded(),opensearchprofile (sameitests/pom.xml), which already uses Docker, andAligning Elasticsearch on the same Docker-based approach the
opensearchprofile uses removes the template-override workaround, eliminates the binary download, and makes both search-engine profiles symmetric.What changed
itests/pom.xml—elasticsearchprofile<elasticsearch.port>9400</elasticsearch.port>and surface it to Failsafe viasystemPropertyVariables, so tests resolve the HTTP port from a single property (value unchanged:9400).elasticsearch-maven-pluginexecution with anio.fabric8:docker-maven-pluginexecution running:docker.elastic.co/elasticsearch/elasticsearch:${elasticsearch.test.version}9200→ host9400${elasticsearch.heap}(default4g, overridable) — aligned with OpenSearchdiscovery.type=single-node,xpack.ml.enabled=false,xpack.security.enabled=false,cluster.routing.allocation.disk.threshold_enabled=false,path.repo=/tmp/snapshots_repository${project.build.directory}/snapshots_repository→/tmp/snapshots_repositorypre-integration-testrunsstop+remove(idempotent cleanup, withignoreRunningContainers) thenstartwithshowLogs;post-integration-testrunsstop(skippable viait.keepContainer).chmod -R ugo+rwxontarget/snapshots_repositoryin the antrununzipstep. The official ES image runs as UID 1000, so on Linux CI the bind-mounted snapshot repository otherwise hitsaccess_deniedduringrepository verifyoperations.itests/pom.xml—opensearchprofilestop-opensearchpost-integration-testexecution (was missing).ignoreRunningContainersto the pre-start cleanup execution.-Dcluster.default.index.settings.number_of_replicas=0fromOPENSEARCH_JAVA_OPTS(JVM property, had no effect on OpenSearch settings).itests/pom.xml— both profilesit.keepContainerproperty (defaultfalse). Whentrue, the post-teststopexecution is skipped so the container stays alive for post-failure inspection.pom.xml(root)<docker-maven-plugin.version>0.48.0</docker-maven-plugin.version>and add the corresponding<pluginManagement>entry so theelasticsearchprofile inherits a single version.build.sh--keep-containerflag wired to-Dit.keepContainer=true, so the container can be kept alive for inspection directly from the build script.itests/src/test/java— test fixesGraphQLListIT: restore thecatchblock and null-guard in thekeepTryingsupplier that were inadvertently removed — without them, a transient HTTP error aborts the poll loop immediately instead of retrying.PropertiesUpdateActionIT: tighten the assert message on thechanges > 0check.Review history (from #759)
The following Copilot review comments were raised on #759 and addressed in this branch:
-Dcluster.default.index.settings.number_of_replicas=0passed as a JVM-Dproperty — removed from bothES_JAVA_OPTSandOPENSEARCH_JAVA_OPTS; Unomi creates its own indices with explicit settings so a cluster-level default isn't needed.-Xms8g -Xmx8g— made configurable via${elasticsearch.heap}(default4g), aligned with the OpenSearch profile.Verification
./build.sh --integration-tests(ES): container starts on9400, all integration tests pass, container stops after the run../build.sh --integration-tests --use-opensearch(OpenSearch): same, container stops after the run../build.sh --integration-tests --keep-container: container remains running after tests for inspection.Follow-ups (tracked under the same JIRA)
Remove
BaseIT.fixDefaultTemplateIfNeeded()and its call incheckSearchEngine()(now dead code under Docker).Migrate16xToCurrentVersionIT: replace the hardcodedES_BASE_URL = "http://localhost:9400"with the dynamicgetSearchPort()resolution.Drop the comments referring to the
elasticsearch-maven-plugintemplate-override workaround.Remove the explicit
<version>pin from the OpenSearch profile'sdocker-maven-plugindeclaration (should inherit frompluginManagement).I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004