Skip to content

UNOMI-921: Replace elasticsearch-maven-plugin with Docker-based Elasticsearch in integration tests#767

Merged
sergehuber merged 10 commits into
masterfrom
UNOMI-921-itests-es-docker
May 29, 2026
Merged

UNOMI-921: Replace elasticsearch-maven-plugin with Docker-based Elasticsearch in integration tests#767
sergehuber merged 10 commits into
masterfrom
UNOMI-921-itests-es-docker

Conversation

@sergehuber
Copy link
Copy Markdown
Contributor

Note: This PR replaces #759, which was accidentally closed when the head branch was renamed from `UNOMI-itests-es-docker` to `UNOMI-921-itests-es-docker` to align local and remote naming. All commit history, review comments, and fixes from #759 are preserved in this branch — see that PR for the full review thread.


Stacked PR (merge order)

Role Branch
Base (merge into) master
Head (this PR) UNOMI-921-itests-es-docker

This PR is stacked: it is the bottom of a chain. Merge into master first; downstream branches that build on top will resync onto the new master tip.


JIRA: https://issues.apache.org/jira/browse/UNOMI-921Replace elasticsearch-maven-plugin with Docker-based Elasticsearch Instance in integration tests.

Why this change

The elasticsearch profile in itests/pom.xml currently uses com.github.alexcojocaru:elasticsearch-maven-plugin to download an Elasticsearch tarball and run it as a forked JVM during the Maven build. This approach:

  • requires downloading Elasticsearch binaries during the build,
  • creates a default_template that overrides user templates on ES 8/9 — currently worked around by BaseIT.fixDefaultTemplateIfNeeded(),
  • is inconsistent with the opensearch profile (same itests/pom.xml), which already uses Docker, and
  • has a more complex lifecycle to manage.

Aligning Elasticsearch on the same Docker-based approach the opensearch profile uses removes the template-override workaround, eliminates the binary download, and makes both search-engine profiles symmetric.

What changed

itests/pom.xmlelasticsearch profile

  • Add <elasticsearch.port>9400</elasticsearch.port> and surface it to Failsafe via systemPropertyVariables, so tests resolve the HTTP port from a single property (value unchanged: 9400).
  • Replace the elasticsearch-maven-plugin execution with an io.fabric8:docker-maven-plugin execution running:
    • Image: docker.elastic.co/elasticsearch/elasticsearch:${elasticsearch.test.version}
    • Port mapping: container 9200 → host 9400
    • Heap: ${elasticsearch.heap} (default 4g, overridable) — aligned with OpenSearch
    • Settings: discovery.type=single-node, xpack.ml.enabled=false, xpack.security.enabled=false, cluster.routing.allocation.disk.threshold_enabled=false, path.repo=/tmp/snapshots_repository
    • Volume bind: ${project.build.directory}/snapshots_repository/tmp/snapshots_repository
    • HTTP wait probe before the integration-test phase
  • Container lifecycle matches the OpenSearch profile exactly: pre-integration-test runs stop + remove (idempotent cleanup, with ignoreRunningContainers) then start with showLogs; post-integration-test runs stop (skippable via it.keepContainer).
  • Add chmod -R ugo+rwx on target/snapshots_repository in the antrun unzip step. The official ES image runs as UID 1000, so on Linux CI the bind-mounted snapshot repository otherwise hits access_denied during repository verify operations.

itests/pom.xmlopensearch profile

  • Add symmetric stop-opensearch post-integration-test execution (was missing).
  • Add ignoreRunningContainers to the pre-start cleanup execution.
  • Remove -Dcluster.default.index.settings.number_of_replicas=0 from OPENSEARCH_JAVA_OPTS (JVM property, had no effect on OpenSearch settings).

itests/pom.xml — both profiles

  • Add it.keepContainer property (default false). When true, the post-test stop execution is skipped so the container stays alive for post-failure inspection.

pom.xml (root)

  • Declare <docker-maven-plugin.version>0.48.0</docker-maven-plugin.version> and add the corresponding <pluginManagement> entry so the elasticsearch profile inherits a single version.

build.sh

  • Add --keep-container flag wired to -Dit.keepContainer=true, so the container can be kept alive for inspection directly from the build script.

itests/src/test/java — test fixes

  • GraphQLListIT: restore the catch block and null-guard in the keepTrying supplier that were inadvertently removed — without them, a transient HTTP error aborts the poll loop immediately instead of retrying.
  • PropertiesUpdateActionIT: tighten the assert message on the changes > 0 check.

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=0 passed as a JVM -D property — removed from both ES_JAVA_OPTS and OPENSEARCH_JAVA_OPTS; Unomi creates its own indices with explicit settings so a cluster-level default isn't needed.
  • ES heap hardcoded at -Xms8g -Xmx8g — made configurable via ${elasticsearch.heap} (default 4g), aligned with the OpenSearch profile.

Verification

  • ./build.sh --integration-tests (ES): container starts on 9400, 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 in checkSearchEngine() (now dead code under Docker).

  • Migrate16xToCurrentVersionIT: replace the hardcoded ES_BASE_URL = "http://localhost:9400" with the dynamic getSearchPort() resolution.

  • Drop the comments referring to the elasticsearch-maven-plugin template-override workaround.

  • Remove the explicit <version> pin from the OpenSearch profile's docker-maven-plugin declaration (should inherit from pluginManagement).

  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004

sergehuber added 10 commits May 18, 2026 15:46
…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.
# 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
@sergehuber sergehuber merged commit 5a5aedb into master May 29, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant