This is an automated email from the ASF dual-hosted git repository.

sergehuber pushed a commit to branch UNOMI-itests-es-docker
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/UNOMI-itests-es-docker by this 
push:
     new df1dc2a8f UNOMI-880 (split A0): migrate Elasticsearch integration 
tests to Docker
df1dc2a8f is described below

commit df1dc2a8f1f568ddead960bb679d56af2fa8b2ac
Author: Serge Huber <[email protected]>
AuthorDate: Mon May 18 15:04:49 2026 +0200

    UNOMI-880 (split A0): migrate Elasticsearch integration tests to Docker
    
    Replace the com.github.alexcojocaru:elasticsearch-maven-plugin (binary
    download + forked JVM) with io.fabric8:docker-maven-plugin so the
    elasticsearch profile of itests runs ES in a Docker container, mirroring
    how the opensearch profile already runs OpenSearch.
    
    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.
    * Replace the elasticsearch-maven-plugin block with a docker-maven-plugin
      block that starts/stops a docker.elastic.co/elasticsearch/elasticsearch
      container, binds target/snapshots_repository to /tmp/snapshots_repository,
      and waits on the HTTP port before the integration-test phase.
    * 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.
    
    This is phase A0 of the PR #757 stack split (see
    docs/PR-757-stack-extraction-tracker.md). It is intentionally small and
    self-contained: no test/code changes, only the test infrastructure switch.
---
 itests/pom.xml | 91 +++++++++++++++++++++++++++++++++++++++-------------------
 pom.xml        |  6 ++++
 2 files changed, 68 insertions(+), 29 deletions(-)

diff --git a/itests/pom.xml b/itests/pom.xml
index 98e98e9e5..0d0ccde8c 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -196,6 +196,14 @@
                         <configuration>
                             <tasks>
                                 <unzip 
src="${project.basedir}/src/test/resources/migration/snapshots_repository.zip" 
dest="${project.build.directory}" />
+                                <!-- Elasticsearch Docker image runs as UID 
1000; Maven on Linux CI (e.g. GitHub Actions) often
+                                     owns target/ as another UID, so 
bind-mounted FS snapshot repos get access_denied
+                                     during repository verification unless the 
tree is world-writable. Skipped on Windows. -->
+                                <exec executable="chmod" osfamily="unix" 
failonerror="true">
+                                    <arg value="-R"/>
+                                    <arg value="ugo+rwx"/>
+                                    <arg 
path="${project.build.directory}/snapshots_repository"/>
+                                </exec>
                             </tasks>
                         </configuration>
                         <goals>
@@ -210,6 +218,9 @@
     <profiles>
         <profile>
             <id>elasticsearch</id>
+            <properties>
+                <elasticsearch.port>9400</elasticsearch.port>
+            </properties>
             <activation>
                 <activeByDefault>true</activeByDefault>
                 <property>
@@ -229,6 +240,7 @@
                             <systemPropertyVariables>
                                 <my.system.property>foo</my.system.property>
                                 
<unomi.search.engine>elasticsearch</unomi.search.engine>
+                                
<elasticsearch.port>${elasticsearch.port}</elasticsearch.port>
                             </systemPropertyVariables>
                         </configuration>
                         <executions>
@@ -247,43 +259,64 @@
                         </executions>
                     </plugin>
                     <plugin>
-                        <groupId>com.github.alexcojocaru</groupId>
-                        <artifactId>elasticsearch-maven-plugin</artifactId>
-                        <!-- REPLACE THE FOLLOWING WITH THE PLUGIN VERSION YOU 
NEED -->
-                        <version>6.29</version>
+                        <groupId>io.fabric8</groupId>
+                        <artifactId>docker-maven-plugin</artifactId>
                         <configuration>
-                            <!-- 
<downloadUrl>https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.2.1-darwin-aarch64.tar
-                            .gz</downloadUrl> -->
-                            
<clusterName>contextElasticSearchITests</clusterName>
-                            <transportPort>9500</transportPort>
-                            <httpPort>9400</httpPort>
-                            <version>${elasticsearch.test.version}</version>
-                            <autoCreateIndex>true</autoCreateIndex>
-                            
<instanceStartupTimeout>120</instanceStartupTimeout>
-                            <environmentVariables>
-                                <ES_JAVA_OPTS>-Xms4g -Xmx4g</ES_JAVA_OPTS>
-                            </environmentVariables>
-                            <instanceSettings>
-                                <properties>
-                                    <xpack.ml.enabled>false</xpack.ml.enabled>
-                                    
<path.repo>${project.build.directory}/snapshots_repository</path.repo>
-                                    
<cluster.routing.allocation.disk.threshold_enabled>false</cluster.routing.allocation.disk.threshold_enabled>
-                                    
<http.cors.allow-methods>OPTIONS,HEAD,GET,POST,PUT,DELETE</http.cors.allow-methods>
-                                    
<http.cors.allow-headers>Authorization,X-Requested-With,X-Auth-Token,Content-Type,Content-Length</http.cors.allow-headers>
-                                </properties>
-                            </instanceSettings>
+                            
<containerNamePattern>itests-elasticsearch</containerNamePattern>
+                            <images>
+                                <image>
+                                    
<name>docker.elastic.co/elasticsearch/elasticsearch:${elasticsearch.test.version}</name>
+                                    <alias>elasticsearch</alias>
+                                    <run>
+                                        <ports>
+                                            
<port>${elasticsearch.port}:9200</port>
+                                        </ports>
+                                        <env>
+                                            
<discovery.type>single-node</discovery.type>
+                                            <ES_JAVA_OPTS>-Xms8g -Xmx8g 
-Dcluster.default.index.settings.number_of_replicas=0</ES_JAVA_OPTS>
+                                            
<xpack.security.enabled>false</xpack.security.enabled>
+                                            
<xpack.ml.enabled>false</xpack.ml.enabled>
+                                            
<path.repo>/tmp/snapshots_repository</path.repo>
+                                            
<cluster.routing.allocation.disk.threshold_enabled>false</cluster.routing.allocation.disk.threshold_enabled>
+                                        </env>
+                                        <volumes>
+                                            <bind>
+                                                
<volume>${project.build.directory}/snapshots_repository:/tmp/snapshots_repository</volume>
+                                            </bind>
+                                        </volumes>
+                                        <wait>
+                                            <http>
+                                                
<url>http://localhost:${elasticsearch.port}</url>
+                                                <method>GET</method>
+                                                <status>200</status>
+                                            </http>
+                                            <time>120000</time>
+                                        </wait>
+                                        
<portPropertyFile>${project.build.directory}/elasticsearch-port.properties</portPropertyFile>
+                                    </run>
+                                </image>
+                            </images>
                         </configuration>
                         <executions>
-                            <!--
-                                The elasticsearch maven plugin goals are by 
default bound to the
-                                pre-integration-test and post-integration-test 
phases
-                            -->
+                            <!-- Force remove existing container before 
starting -->
+                            <execution>
+                                <id>remove-existing-container</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>stop</goal> <!-- Stops the container 
if running -->
+                                    <goal>remove</goal> <!-- Removes the 
container -->
+                                </goals>
+                            </execution>
+
                             <execution>
                                 <id>start-elasticsearch</id>
                                 <phase>pre-integration-test</phase>
                                 <goals>
-                                    <goal>runforked</goal>
+                                    <goal>start</goal>
                                 </goals>
+                                <configuration>
+                                    <showLogs>true</showLogs>
+                                </configuration>
                             </execution>
                             <execution>
                                 <id>stop-elasticsearch</id>
diff --git a/pom.xml b/pom.xml
index 25360797d..f5c1c2aa5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -146,6 +146,7 @@
         <maven-site.plugin.version>3.21.0</maven-site.plugin.version>
         <apache-rat.plugin.version>0.16.1</apache-rat.plugin.version>
         <jgitflow.plugin.version>1.0-m5.1</jgitflow.plugin.version>
+        <docker-maven-plugin.version>0.48.0</docker-maven-plugin.version>
 
         <node.version>v16.20.2</node.version>
         <yarn.version>v1.22.19</yarn.version>
@@ -865,6 +866,11 @@
                     <artifactId>dependency-check-maven</artifactId>
                     <version>${dependency-check.plugin.version}</version>
                 </plugin>
+                <plugin>
+                    <groupId>io.fabric8</groupId>
+                    <artifactId>docker-maven-plugin</artifactId>
+                    <version>${docker-maven-plugin.version}</version>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>

Reply via email to