Skip to content

Commit

Permalink
ci(ITs): support JBoss ITs with GitHub secrets (#3469)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Dec 20, 2023
1 parent 6a77a76 commit 140392c
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .ci/scripts/jboss-docker-images.txt
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions .ci/scripts/jboss-pull.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions .ci/scripts/jboss-upload.sh
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion docs/supported-technologies.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Other Servlet 3+ compliant servers will most likely work as well.
|8+

|<<setup-jboss-wildfly,JBoss EAP>>
|6.4, 7.0, 7.1, 7.2
|6.4, 7.x

|<<setup-jetty,Jetty>> (only the `ServletContextHandler` is supported)
|9.2, 9.3, 9.4
Expand Down
15 changes: 15 additions & 0 deletions integration-tests/application-server-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,37 @@
</dependencies>

<profiles>
<!-- application servers only jboss -->
<profile>
<id>ci-jboss-integration-tests</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skip.integration.test>false</skip.integration.test>
<failsafe.includes>**/JBossIT.java</failsafe.includes>
</properties>
</profile>
<!-- application servers but jboss -->
<profile>
<id>ci-application-server-integration-tests</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skip.integration.test>false</skip.integration.test>
<failsafe.excludes>**/JBossIT.java</failsafe.excludes>
</properties>
</profile>
<!-- non application servers -->
<profile>
<id>ci-non-application-server-integration-tests</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skip.integration.test>true</skip.integration.test>
<failsafe.excludes>**/JBossIT.java</failsafe.excludes>
</properties>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object[]> 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},
});
}

Expand Down
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,40 @@
</plugins>
</build>
</profile>
<profile>
<!-- copies behavior from app server tests for jboss -->
<id>ci-jboss-integration-tests</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<!--
By default, disables all integration tests.
In integration-tests/application-server-integration-tests/pom.xml,
only that module is included by overriding skip.integration.test to false.
-->
<skip.integration.test>true</skip.integration.test>
<maven.javadoc.skip>true</maven.javadoc.skip>
<animal.sniffer.skip>true</animal.sniffer.skip>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skipTests>${skip.integration.test}</skipTests>
<rerunFailingTestsCount>3</rerunFailingTestsCount>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>different-test-jdk</id>
<activation>
Expand Down

0 comments on commit 140392c

Please sign in to comment.