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

sergehuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a5aedba7 UNOMI-921: Replace elasticsearch-maven-plugin with 
Docker-based Elasticsearch in integration tests (#767)
5a5aedba7 is described below

commit 5a5aedba7691a23d322eaedb8d6f8ad403ecc563
Author: Serge Huber <[email protected]>
AuthorDate: Fri May 29 11:58:09 2026 +0200

    UNOMI-921: Replace elasticsearch-maven-plugin with Docker-based 
Elasticsearch in integration tests (#767)
---
 build.sh                                           |  25 +++--
 itests/pom.xml                                     | 121 +++++++++++++++------
 .../unomi/itests/PropertiesUpdateActionIT.java     |   5 +-
 pom.xml                                            |   6 +
 4 files changed, 109 insertions(+), 48 deletions(-)

diff --git a/build.sh b/build.sh
index 4b8251326..94891527d 100755
--- a/build.sh
+++ b/build.sh
@@ -19,8 +19,6 @@
 
################################################################################
 
 set -e  # Exit on error
-# Truncate $BASH_COMMAND in the trap (where it correctly reflects the failing
-# command) to avoid ARG_MAX limits after a failed mvn invocation.
 trap 'handle_error $? $LINENO "${BASH_COMMAND:0:200}"' ERR
 
 # Error handling function
@@ -265,6 +263,7 @@ IT_DEBUG=false
 IT_DEBUG_PORT=5006
 IT_DEBUG_SUSPEND=false
 SKIP_MIGRATION_TESTS=false
+KEEP_CONTAINER=false
 
 # Enhanced usage function with color support
 usage() {
@@ -303,7 +302,8 @@ EOF
         echo -e "  ${CYAN}--it-debug-port PORT${NC}       Set integration test 
debug port"
         echo -e "  ${CYAN}--it-debug-suspend${NC}         Suspend integration 
test until debugger connects"
         echo -e "  ${CYAN}--skip-migration-tests${NC}     Skip 
migration-related tests"
-        echo -e "  ${CYAN}--ci${NC}                       CI mode: no Karaf, 
no Maven cache, Maven -B -ntp, non-interactive"
+        echo -e "  ${CYAN}--keep-container${NC}           Keep search engine 
container running after tests (for post-failure inspection)"
+        echo -e "  ${CYAN}--ci${NC}                       CI mode: no Karaf, 
no Maven build cache, non-interactive"
     else
         cat << "EOF"
      _    _ _____ _      ____
@@ -337,7 +337,8 @@ EOF
         echo "  --it-debug-port PORT      Set integration test debug port"
         echo "  --it-debug-suspend        Suspend integration test until 
debugger connects"
         echo "  --skip-migration-tests    Skip migration-related tests"
-        echo "  --ci                      CI mode: no Karaf, no Maven cache, 
Maven -B -ntp, non-interactive"
+        echo "  --keep-container          Keep search engine container running 
after tests (for post-failure inspection)"
+        echo "  --ci                      CI mode: no Karaf, no Maven build 
cache, non-interactive"
     fi
 
     echo
@@ -468,6 +469,9 @@ while [ "$1" != "" ]; do
         --skip-migration-tests)
             SKIP_MIGRATION_TESTS=true
             ;;
+        --keep-container)
+            KEEP_CONTAINER=true
+            ;;
         --ci)
             NO_KARAF=true
             USE_MAVEN_CACHE=false
@@ -784,11 +788,6 @@ check_requirements() {
 MVN_CMD="mvn"
 MVN_OPTS=""
 
-# CI / non-interactive: no download progress UI, batch mode (matches former 
workflow mvn -ntp)
-if is_non_interactive; then
-    MVN_OPTS="$MVN_OPTS -B -ntp"
-fi
-
 # Add Maven debug option
 if [ "$MAVEN_DEBUG" = true ]; then
     MVN_OPTS="$MVN_OPTS -X"
@@ -874,6 +873,12 @@ if [ "$RUN_INTEGRATION_TESTS" = true ]; then
         MVN_OPTS="$MVN_OPTS -Dit.test.exclude.pattern=**/migration/**/*IT.java"
         echo "Skipping migration tests"
     fi
+
+    # Keep container running after tests if requested
+    if [ "$KEEP_CONTAINER" = true ]; then
+        MVN_OPTS="$MVN_OPTS -Dit.keepContainer=true"
+        echo "Search engine container will be kept running after tests"
+    fi
 else
     if [ "$SKIP_TESTS" = true ]; then
         PROFILES="$PROFILES,!integration-tests,!run-tests"
@@ -932,7 +937,6 @@ if [ "$HAS_COLORS" -eq 1 ]; then
 else
     echo "Running: $MVN_CMD clean $MVN_OPTS"
 fi
-# shellcheck disable=SC2086
 $MVN_CMD clean $MVN_OPTS || {
     print_status "error" "Maven clean failed"
     exit 1
@@ -944,7 +948,6 @@ if [ "$HAS_COLORS" -eq 1 ]; then
 else
     echo "Running: $MVN_CMD install $MVN_OPTS"
 fi
-# shellcheck disable=SC2086
 $MVN_CMD install $MVN_OPTS || {
     print_status "error" "Maven install failed"
     exit 1
diff --git a/itests/pom.xml b/itests/pom.xml
index 98e98e9e5..239ef3015 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -32,6 +32,8 @@
         <unomi.search.engine>elasticsearch</unomi.search.engine>
         <use.opensearch>false</use.opensearch>
         <docker.container.name>itests-opensearch</docker.container.name>
+        <!-- Set to true to keep the search engine container running after 
tests (useful for post-failure inspection) -->
+        <it.keepContainer>false</it.keepContainer>
     </properties>
 
     <dependencyManagement>
@@ -196,6 +198,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 +220,10 @@
     <profiles>
         <profile>
             <id>elasticsearch</id>
+            <properties>
+                <elasticsearch.port>9400</elasticsearch.port>
+                <elasticsearch.heap>4g</elasticsearch.heap>
+            </properties>
             <activation>
                 <activeByDefault>true</activeByDefault>
                 <property>
@@ -229,6 +243,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,47 +262,74 @@
                         </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>-Xms${elasticsearch.heap} -Xmx${elasticsearch.heap}</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; ignore failure if no container exists yet -->
+                            <execution>
+                                <id>remove-existing-container</id>
+                                <phase>pre-integration-test</phase>
+                                <configuration>
+                                    
<ignoreRunningContainers>true</ignoreRunningContainers>
+                                </configuration>
+                                <goals>
+                                    <goal>stop</goal>
+                                    <goal>remove</goal>
+                                </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>
                                 <phase>post-integration-test</phase>
+                                <configuration>
+                                    <skip>${it.keepContainer}</skip>
+                                </configuration>
                                 <goals>
                                     <goal>stop</goal>
                                 </goals>
@@ -354,7 +396,7 @@
                                         </ports>
                                         <env>
                                             
<discovery.type>single-node</discovery.type>
-                                            <OPENSEARCH_JAVA_OPTS>-Xms4g 
-Xmx4g 
-Dcluster.default.index.settings.number_of_replicas=0</OPENSEARCH_JAVA_OPTS>
+                                            <OPENSEARCH_JAVA_OPTS>-Xms4g 
-Xmx4g</OPENSEARCH_JAVA_OPTS>
                                             
<path.repo>/tmp/snapshots_repository</path.repo>
                                             
<plugins.security.disabled>true</plugins.security.disabled>
                                             
<OPENSEARCH_INITIAL_ADMIN_PASSWORD>Unomi.1ntegrat10n.Tests</OPENSEARCH_INITIAL_ADMIN_PASSWORD>
@@ -378,13 +420,16 @@
                             </images>
                         </configuration>
                         <executions>
-                            <!-- Force remove existing container before 
starting -->
+                            <!-- Force remove existing container before 
starting; ignore failure if no container exists yet -->
                             <execution>
                                 <id>remove-existing-container</id>
                                 <phase>pre-integration-test</phase>
+                                <configuration>
+                                    
<ignoreRunningContainers>true</ignoreRunningContainers>
+                                </configuration>
                                 <goals>
-                                    <goal>stop</goal> <!-- Stops the container 
if running -->
-                                    <goal>remove</goal> <!-- Removes the 
container -->
+                                    <goal>stop</goal>
+                                    <goal>remove</goal>
                                 </goals>
                             </execution>
 
@@ -398,6 +443,16 @@
                                     <showLogs>true</showLogs>
                                 </configuration>
                             </execution>
+                            <execution>
+                                <id>stop-opensearch</id>
+                                <phase>post-integration-test</phase>
+                                <configuration>
+                                    <skip>${it.keepContainer}</skip>
+                                </configuration>
+                                <goals>
+                                    <goal>stop</goal>
+                                </goals>
+                            </execution>
                         </executions>
                     </plugin>
                 </plugins>
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java 
b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
index 1bc731e42..66f1de7fc 100644
--- a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
@@ -93,10 +93,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         updateProperties.setProperty(UpdatePropertiesAction.TARGET_TYPE_KEY, 
"profile");
 
         int changes = eventService.send(updateProperties);
-
-        LOGGER.info("Changes of the event : {}", changes);
-
-        Assert.assertTrue(changes > 0);
+        Assert.assertTrue("eventService.send() reported no changes — action 
may not have fired", changes > 0);
         // Current profile on the event is updated in memory; do not poll 
persistence here.
         Assert.assertEquals("UPDATED FIRST NAME CURRENT PROFILE", 
profile.getProperty("firstName"));
     }
diff --git a/pom.xml b/pom.xml
index 174e68308..f7e85f403 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>
@@ -867,6 +868,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