Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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"
_ _ _____ _ ____
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
121 changes: 88 additions & 33 deletions itests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>

Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ public void testUpdateProperties_CurrentProfile() {
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"));
}
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Loading