77
88import static io .opentelemetry .contrib .jmxscraper .target_systems .MetricAssertions .assertSum ;
99import static io .opentelemetry .contrib .jmxscraper .target_systems .MetricAssertions .assertSumWithAttributes ;
10+ import static org .assertj .core .api .Assertions .assertThat ;
1011import static org .assertj .core .api .Assertions .entry ;
1112
1213import io .opentelemetry .contrib .jmxscraper .JmxScraperContainer ;
1314import java .io .IOException ;
1415import java .nio .file .Files ;
1516import java .nio .file .Path ;
17+ import java .nio .file .Paths ;
1618import java .time .Duration ;
1719import org .junit .jupiter .api .AfterAll ;
1820import org .testcontainers .containers .GenericContainer ;
@@ -36,23 +38,36 @@ public static void cleanup() throws IOException {
3638 protected GenericContainer <?> createTargetContainer (int jmxPort ) {
3739 // JMX port is ignored here as we are using HTTP management interface
3840
41+ String appWar = System .getProperty ("app.war.path" );
42+ Path appWarPath = Paths .get (appWar );
43+ assertThat (appWarPath ).isNotEmptyFile ().isReadable ();
44+
3945 return new GenericContainer <>(
4046 new ImageFromDockerfile ()
4147 .withDockerfileFromBuilder (
4248 builder ->
4349 builder
44- .from ("jboss /wildfly:23 .0.1.Final" )
50+ .from ("quay.io /wildfly/wildfly:32 .0.1.Final-jdk11 " )
4551 // user/pwd needed for remote JMX access
4652 .run ("/opt/jboss/wildfly/bin/add-user.sh user password --silent" )
4753 // standalone with management (HTTP) interface enabled
4854 .cmd (
4955 "/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0" )
5056 .expose (8080 , 9990 )
5157 .build ()))
58+ .withCopyFileToContainer (
59+ MountableFile .forHostPath (appWarPath ),
60+ "/opt/jboss/wildfly/standalone/deployments/testapp.war" )
5261 .withStartupTimeout (Duration .ofMinutes (2 ))
5362 .waitingFor (Wait .forLogMessage (".*Http management interface listening on.*" , 1 ));
5463 }
5564
65+ @ Override
66+ protected String scraperBaseImage () {
67+ // we need to run the scraper with Java 11+ because jboss client jar is using Java 11
68+ return "eclipse-temurin:11.0.25_9-jdk-noble" ;
69+ }
70+
5671 @ Override
5772 protected JmxScraperContainer customizeScraperContainer (
5873 JmxScraperContainer scraper , GenericContainer <?> target ) {
@@ -159,7 +174,6 @@ protected void verifyMetrics() {
159174 "{transaction}" ,
160175 attrs -> attrs .containsOnly (entry ("cause" , "system" )),
161176 attrs -> attrs .containsOnly (entry ("cause" , "resource" )),
162- attrs -> attrs .containsOnly (entry ("cause" , "application" )))
163- );
177+ attrs -> attrs .containsOnly (entry ("cause" , "application" ))));
164178 }
165179}
0 commit comments