diff --git a/.ci/scripts/jboss-docker-images.txt b/.ci/scripts/jboss-docker-images.txt new file mode 100644 index 0000000000..44a4285164 --- /dev/null +++ b/.ci/scripts/jboss-docker-images.txt @@ -0,0 +1,6 @@ +registry.redhat.io/jboss-eap-7/eap70-openshift:1.7 +registry.access.redhat.com/jboss-eap-7/eap71-openshift +registry.access.redhat.com/jboss-eap-7/eap72-openshift +registry.redhat.io/jboss-eap-7/eap73-openjdk11-openshift-rhel8:7.3.10 +registry.redhat.io/jboss-eap-7/eap74-openjdk11-openshift-rhel8:7.4.0 +registry.redhat.io/jboss-eap-7/eap74-openjdk17-openshift-rhel8:7.4.14 diff --git a/.ci/scripts/jboss-pull.sh b/.ci/scripts/jboss-pull.sh new file mode 100755 index 0000000000..60ef187f62 --- /dev/null +++ b/.ci/scripts/jboss-pull.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Bash strict mode +set -eo pipefail + +## This script is used by the CI to be able to re-tag the docker images +## to use the official docker namespace. +## Or by an Elastic employee to configure the docker images as needed. +while read -r i ; do + [[ -z $i ]] && continue + name="${i##*/}" + echo "::group::$name" + docker pull docker.elastic.co/observability-ci/$name --platform linux/amd64 + docker tag docker.elastic.co/observability-ci/$name $i + echo "::endgroup::" +done < .ci/scripts/jboss-docker-images.txt + +if [ "$CI" == "true" ] ;then + echo "::group::docker-images" + docker images + echo "::endgroup::" +fi \ No newline at end of file diff --git a/.ci/scripts/jboss-upload.sh b/.ci/scripts/jboss-upload.sh new file mode 100755 index 0000000000..9f9ca784a0 --- /dev/null +++ b/.ci/scripts/jboss-upload.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Bash strict mode +set -eo pipefail + +## This script is called manually when a new Docker image is added. +while read -r i ; do + [[ -z $i ]] && continue + name="${i##*/}" + echo "::group::$name" + docker pull --platform linux/amd64 $i + docker tag $i docker.elastic.co/observability-ci/$name + docker push docker.elastic.co/observability-ci/$name + echo "::endgroup::" +done < .ci/scripts/jboss-docker-images.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4574e507a3..7d6f8b245b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -320,3 +320,35 @@ jobs: path: | **/junit-*.xml **/TEST-*.xml + + jboss: + name: JBoss integration tests + runs-on: ubuntu-latest + needs: build + if: github.event_name != 'pull_request' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false + steps: + - uses: actions/checkout@v4 + - uses: elastic/apm-pipeline-library/.github/actions/docker-login@current + with: + registry: docker.elastic.co + secret: secret/observability-team/ci/docker-registry/prod + url: ${{ secrets.VAULT_ADDR }} + roleId: ${{ secrets.VAULT_ROLE_ID }} + secretId: ${{ secrets.VAULT_SECRET_ID }} + - uses: ./.github/workflows/unstash + with: + name: build + path: ${{ github.workspace }} + - name: Pull JBoss docker images + run: .ci/scripts/jboss-pull.sh + - uses: ./.github/workflows/maven-goal + with: + command: ./mvnw -q -P ci-jboss-integration-tests verify + - name: Store test results + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: test-results + path: | + **/junit-*.xml + **/TEST-*.xml diff --git a/apm-agent-common/src/test/java/co/elastic/apm/agent/test/AgentTestContainer.java b/apm-agent-common/src/test/java/co/elastic/apm/agent/test/AgentTestContainer.java index 363b31b5a0..e73a391afe 100644 --- a/apm-agent-common/src/test/java/co/elastic/apm/agent/test/AgentTestContainer.java +++ b/apm-agent-common/src/test/java/co/elastic/apm/agent/test/AgentTestContainer.java @@ -270,16 +270,16 @@ public void start() { log.info("starting container with {} = {}", jvmEnvironmentVariable, value); } + // log app server output for easier debugging + withLogConsumer(new Slf4jLogConsumer(log)); + try { super.start(); } catch (RuntimeException e) { log.error("unable to start container, set breakpoint where this log is generated to debug", e); } - // send container logs to logger for easier debug by default - followOutput(new Slf4jLogConsumer(log)); - //.withLogConsumer(TestContainersUtils.createSlf4jLogConsumer(MockServerContainer.class)) } private static String javaAgentArg(AgentFileAccessor.Variant javaAgentArgumentVariant) { diff --git a/docs/supported-technologies.asciidoc b/docs/supported-technologies.asciidoc index 57102e4a7c..22ee4fc0d3 100644 --- a/docs/supported-technologies.asciidoc +++ b/docs/supported-technologies.asciidoc @@ -204,7 +204,7 @@ Other Servlet 3+ compliant servers will most likely work as well. |8+ |<> -|6.4, 7.0, 7.1, 7.2 +|6.4, 7.x |<> (only the `ServletContextHandler` is supported) |9.2, 9.3, 9.4 diff --git a/integration-tests/application-server-integration-tests/pom.xml b/integration-tests/application-server-integration-tests/pom.xml index 8e61ef2903..252935d80e 100644 --- a/integration-tests/application-server-integration-tests/pom.xml +++ b/integration-tests/application-server-integration-tests/pom.xml @@ -188,6 +188,18 @@ + + + ci-jboss-integration-tests + + false + + + false + **/JBossIT.java + + + ci-application-server-integration-tests @@ -195,8 +207,10 @@ false + **/JBossIT.java + ci-non-application-server-integration-tests @@ -204,6 +218,7 @@ true + **/JBossIT.java diff --git a/integration-tests/application-server-integration-tests/src/test/java/co/elastic/apm/servlet/JBossIT.java b/integration-tests/application-server-integration-tests/src/test/java/co/elastic/apm/servlet/JBossIT.java index bb22936f35..f9752ac4fd 100644 --- a/integration-tests/application-server-integration-tests/src/test/java/co/elastic/apm/servlet/JBossIT.java +++ b/integration-tests/application-server-integration-tests/src/test/java/co/elastic/apm/servlet/JBossIT.java @@ -19,41 +19,56 @@ package co.elastic.apm.servlet; import co.elastic.apm.agent.test.AgentTestContainer; -import co.elastic.apm.servlet.tests.CdiApplicationServerTestApp; -import co.elastic.apm.servlet.tests.JBossServletApiTestApp; -import co.elastic.apm.servlet.tests.JavaxExternalPluginTestApp; -import co.elastic.apm.servlet.tests.JsfApplicationServerTestApp; -import co.elastic.apm.servlet.tests.SoapTestApp; -import co.elastic.apm.servlet.tests.TestApp; +import co.elastic.apm.servlet.tests.*; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; import java.util.Arrays; @RunWith(Parameterized.class) public class JBossIT extends AbstractServletContainerIntegrationTest { - public JBossIT(final String jbossVersion) { - super(AgentTestContainer.appServer("registry.access.redhat.com/" + jbossVersion) - .withContainerName("jboss") - .withHttpPort(8080) - // set JVM arguments through JAVA_OPTS - .withJvmArgumentsVariable("JAVA_OPTS") - // this overrides the defaults, so we have to manually re-add preferIPv4Stack - .withSystemProperty("java.net.preferIPv4Stack", "true") - // the other defaults don't seem to be important - .withSystemProperty("jboss.modules.system.pkgs", "org.jboss.logmanager,jdk.nashorn.api,com.sun.crypto.provider") - .withDeploymentPath("/opt/eap/standalone/deployments"), + public JBossIT(final String jbossImage, boolean preserveDefaults) { + super(jbossContainer(jbossImage, preserveDefaults), "jboss-application"); } + private static AgentTestContainer.AppServer jbossContainer(String image, boolean preserveDefaults) { + AgentTestContainer.AppServer jboss = AgentTestContainer.appServer(image) + .withContainerName("jboss") + .withHttpPort(8080) + // set JVM arguments through JAVA_OPTS + .withJvmArgumentsVariable("JAVA_OPTS") + + .withDeploymentPath("/opt/eap/standalone/deployments") + .waitingFor(new HttpWaitStrategy().forPort(8080).forStatusCode(200)); + + if (preserveDefaults) { + // for older versions setting JAVA_OPTS means overwriting the defaults + // so we have to manually re-add some of them like 'preferIPv4Stack' and 'jboss.modules.system.pkgs' + // other defaults do not seem to impact test thus we ignore them + jboss.withSystemProperty("java.net.preferIPv4Stack", "true") + // the other defaults don't seem to be important + .withSystemProperty("jboss.modules.system.pkgs", "org.jboss.logmanager,jdk.nashorn.api,com.sun.crypto.provider"); + } + + return jboss; + } + @Parameterized.Parameters(name = "JBoss {0}") public static Iterable data() { + // When running in GitHub actions if a new docker image is added, please + // update the list of these docker images in .ci/scripts/jboss-docker-images.txt + // then you can run .ci/scripts/jboss-upload.sh to upload these new docker images + // to the internal docker registry. return Arrays.asList(new Object[][]{ - {"jboss-eap-6/eap64-openshift"}, -// {"jboss-eap-7/eap70-openshift"}, // disabled as not available anymore in public registry - {"jboss-eap-7/eap71-openshift"}, - {"jboss-eap-7/eap72-openshift"} + {"registry.redhat.io/jboss-eap-7/eap70-openshift:1.7", true}, + {"registry.access.redhat.com/jboss-eap-7/eap71-openshift", true}, + {"registry.access.redhat.com/jboss-eap-7/eap72-openshift", true}, + {"registry.redhat.io/jboss-eap-7/eap73-openjdk11-openshift-rhel8:7.3.10", true}, + {"registry.redhat.io/jboss-eap-7/eap74-openjdk11-openshift-rhel8:7.4.0", false}, + {"registry.redhat.io/jboss-eap-7/eap74-openjdk17-openshift-rhel8:7.4.14", false}, }); } diff --git a/pom.xml b/pom.xml index f097032b08..b59df778b6 100644 --- a/pom.xml +++ b/pom.xml @@ -240,6 +240,40 @@ + + + ci-jboss-integration-tests + + false + + + + true + true + true + + + + + maven-failsafe-plugin + + ${skip.integration.test} + 3 + + + + maven-surefire-plugin + + true + + + + + different-test-jdk