Skip to content
Permalink
Browse files
ARTEMIS-3749 e2e-tests improvements
Scripts:
- Fix the preapre-docker.sh to exit with 0 instead of 1 on success

On pom files:
- Change e2e-tests variable names to e2e-tests.xxxxxx for clarity on
  e2e-tests variables
- Add e2e-tests.skipImageBuild variable to control if the docker image
  will be build (defaults to not build)
- Add e2e-tests.dockerfile variable to specify the dockerfile to be
  used (defaults to Dockerfile-centos)
- Bump testcontainers version to 1.16.3
- Add artemis distribution dependency since the docker image build
  depends on it

On ContainerService class:
- Fix exposePorts and exporseFolder to use SELinux shared mode
  otherwise the mount fails on machines with SELinux enabled
- Move the logic to use specific user on container from generic start
  method to broker specific method to avoid affect other images
- Update the broker image name to a more generic name (activemq-artemis
  instead of artemis-centos)
- Update the broker image tag to match with the project version in pom
  file
  • Loading branch information
tlbueno authored and clebertsuconic committed Mar 30, 2022
1 parent 7d03f71 commit dbd60d0afb9844406b0727116d86dcd9df0caf39
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 24 deletions.
@@ -73,7 +73,7 @@ tag names for the purpose of this guide
For more info read the readme.md
HERE
exit 1
exit 0
}

while [ "$#" -ge 1 ]
@@ -181,4 +181,4 @@ cp ./docker-run.sh "$ARTEMIS_DIST/docker"
echo "Docker file support files at : $ARTEMIS_DIST/docker"
tree "$ARTEMIS_DIST/docker"

next_step
next_step
25 pom.xml
@@ -162,6 +162,9 @@
<version.jaxb.runtime>2.3.3</version.jaxb.runtime>
<paho.client.mqtt.version>1.2.5</paho.client.mqtt.version>
<postgresql.version>42.3.3</postgresql.version>
<testcontainers.version>1.16.3</testcontainers.version>
<exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>

<!-- for JakrtaEE -->
<version.batavia>1.0.10.Final</version.batavia>

@@ -194,7 +197,9 @@
<skipPerformanceTests>true</skipPerformanceTests>
<skipRestTests>true</skipRestTests>
<skipActiveMQ5Tests>true</skipActiveMQ5Tests>
<skipE2ETests>true</skipE2ETests>

<e2e-tests.skipTests>true</e2e-tests.skipTests>
<e2e-tests.skipImageBuild>true</e2e-tests.skipImageBuild>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -1031,6 +1036,19 @@
<scope>test</scope>
<!-- License: EPL 2.0 -->
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>selenium</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</dependencyManagement>
@@ -1742,6 +1760,11 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>

@@ -28,16 +28,40 @@
<name>End-to-End Tests</name>

<properties>
<activemq.basedir>${project.basedir}/../../</activemq.basedir>
<e2ets-surefire-extra-args />
<activemq.basedir>${project.basedir}/../..</activemq.basedir>
<e2e-tests.surefire-extra-args/>
<e2e-tests.dockerfile>Dockerfile-centos</e2e-tests.dockerfile>
<e2e-tests.skipImageBuild>true</e2e-tests.skipImageBuild>
<e2e-tests.skipTests>true</e2e-tests.skipTests>
<distributionDir>${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version}</distributionDir>
<container-service-argline>-DContainerService.artemis-image.version=${project.version} -DContainerService.artemis-image.userid="1000"</container-service-argline>
</properties>

<dependencies>
<dependency>
<!-- this dependency is here to make sure this module is only executed
after the distribution is created.
Otherwise it will get here before the build eventually.
e.g if you use mvn install -T 20 -->
<groupId>org.apache.activemq</groupId>
<artifactId>apache-artemis</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client-all</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jakarta-client-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.16.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
@@ -75,6 +99,50 @@

<build>
<plugins>
<plugin>
<!-- TODO: Review Codehaus usage...ARTEMIS-3750 -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-container-image</id>
<phase>generate-test-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${e2e-tests.skipImageBuild}</skip>
<executable>./prepare-docker.sh</executable>
<workingDirectory>${activemq.basedir}/artemis-docker</workingDirectory>
<arguments>
<argument>--from-local-dist</argument>
<argument>--local-dist-path</argument>
<argument>${distributionDir}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>build-container-image</id>
<phase>generate-test-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${e2e-tests.skipImageBuild}</skip>
<executable>docker</executable>
<workingDirectory>${distributionDir}</workingDirectory>
<arguments>
<argument>build</argument>
<argument>--file</argument>
<argument>${distributionDir}/docker/${e2e-tests.dockerfile}</argument>
<argument>--tag</argument>
<argument>activemq-artemis:${project.version}</argument>
<argument>${distributionDir}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-maven-plugin</artifactId>
@@ -289,10 +357,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipE2ETests}</skipTests>
<argLine>${e2ets-surefire-extra-args} ${activemq-surefire-argline} -Dorg.apache.activemq.artemis.tests.e2e.common.ContainerService.service.userid="1000"</argLine>
<skipTests>${e2e-tests.skipTests}</skipTests>
<argLine>${e2e-tests.surefire-extra-args} ${activemq-surefire-argline} ${container-service-argline}</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>
@@ -18,7 +18,6 @@
package org.apache.activemq.artemis.tests.e2e.common;

import javax.jms.ConnectionFactory;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -27,8 +26,10 @@

import org.apache.activemq.artemis.tests.util.CFUtil;
import org.junit.Assert;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.SelinuxContext;
import org.testcontainers.containers.output.OutputFrame;
import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
@@ -183,7 +184,13 @@ public Object newNetwork() {

@Override
public Object newBrokerImage() {
return new GenericContainer<>(DockerImageName.parse("artemis-centos"));
String imageVersion = System.getProperty("ContainerService.artemis-image.version", "latest");
GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("activemq-artemis:" + imageVersion));
String userId = System.getProperty("ContainerService.artemis-image.userid", "");
if (!userId.isEmpty()) {
container.withCreateContainerCmdModifier(cmd -> cmd.withUser(userId));
}
return container;
}

@Override
@@ -206,15 +213,15 @@ public void exposeFile(Object container, String hostPath, String containerPath)
File file = new File(hostPath);
Assert.assertTrue(file.exists());
Assert.assertFalse(file.isDirectory());
((GenericContainer)container).withFileSystemBind(hostPath, containerPath);
((GenericContainer)container).addFileSystemBind(hostPath, containerPath, BindMode.READ_WRITE, SelinuxContext.SHARED);
}

@Override
public void exposeFolder(Object container, String hostPath, String containerPath) {
File file = new File(hostPath);
Assert.assertTrue(file.exists());
Assert.assertTrue(file.isDirectory());
((GenericContainer)container).withFileSystemBind(hostPath, containerPath);
((GenericContainer)container).addFileSystemBind(hostPath, containerPath, BindMode.READ_WRITE, SelinuxContext.SHARED);
}

@Override
@@ -233,13 +240,8 @@ public void exposeBrokerHome(Object container, String brokerHome) {
@Override
public void start(Object containerObj) {
GenericContainer<?> container = (GenericContainer) containerObj;
String userId = System.getProperty(ContainerService.class.getName() + ".service.userid", "");
if (!userId.isEmpty()) {
container.withCreateContainerCmdModifier(cmd -> cmd.withUser(userId));
}

((GenericContainer)container).setStartupCheckStrategy(new IsRunningStartupCheckStrategy());
((GenericContainer)container).start();
container.setStartupCheckStrategy(new IsRunningStartupCheckStrategy());
container.start();
}

@Override
@@ -139,7 +139,8 @@
<profile>
<id>e2e-tests</id>
<properties>
<skipE2ETests>false</skipE2ETests>
<e2e-tests.skipTests>false</e2e-tests.skipTests>
<e2e-tests.skipImageBuild>false</e2e-tests.skipImageBuild>
</properties>
</profile>
</profiles>
@@ -151,8 +151,6 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>selenium</artifactId>
<version>1.16.2</version>
<scope>test</scope>
</dependency>
<!-- this dependency is needed for CFUtil and other tools from integration-tests -->
<dependency>

0 comments on commit dbd60d0

Please sign in to comment.