This is an automated email from the ASF dual-hosted git repository. clebertsuconic pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push: new dbd60d0 ARTEMIS-3749 e2e-tests improvements dbd60d0 is described below commit dbd60d0afb9844406b0727116d86dcd9df0caf39 Author: Tiago Bueno <49003339+tlbu...@users.noreply.github.com> AuthorDate: Thu Mar 24 12:24:45 2022 -0300 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 --- artemis-docker/prepare-docker.sh | 4 +- pom.xml | 25 ++++++- tests/e2e-tests/pom.xml | 82 ++++++++++++++++++++-- .../artemis/tests/e2e/common/ContainerService.java | 24 ++++--- tests/pom.xml | 3 +- tests/smoke-tests/pom.xml | 2 - 6 files changed, 116 insertions(+), 24 deletions(-) diff --git a/artemis-docker/prepare-docker.sh b/artemis-docker/prepare-docker.sh index 017c1f5..53af6fd 100755 --- a/artemis-docker/prepare-docker.sh +++ b/artemis-docker/prepare-docker.sh @@ -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 \ No newline at end of file +next_step diff --git a/pom.xml b/pom.xml index b3030da..2ae1b30 100644 --- a/pom.xml +++ b/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> diff --git a/tests/e2e-tests/pom.xml b/tests/e2e-tests/pom.xml index aafff27..09f606a 100644 --- a/tests/e2e-tests/pom.xml +++ b/tests/e2e-tests/pom.xml @@ -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> @@ -76,6 +100,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> <executions> @@ -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> \ No newline at end of file +</project> diff --git a/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/ContainerService.java b/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/ContainerService.java index 81918d8..e44e503 100644 --- a/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/ContainerService.java +++ b/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/ContainerService.java @@ -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 java.util.function.Consumer; 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 abstract class ContainerService { @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,7 +213,7 @@ public abstract class ContainerService { 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 @@ -214,7 +221,7 @@ public abstract class ContainerService { 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 abstract class ContainerService { @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 diff --git a/tests/pom.xml b/tests/pom.xml index 9fc67de..0f93f88 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -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> diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml index d55ed53..ddd325d 100644 --- a/tests/smoke-tests/pom.xml +++ b/tests/smoke-tests/pom.xml @@ -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>