Skip to content

Commit

Permalink
Adding unit test for IBM G9 GC metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosroman committed Aug 7, 2024
1 parent c51e3da commit 713eb16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/test/java/org/datadog/jmxfetch/TestGCMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ public void testDefaultNewGCMetricsUseGenerationalZGC() throws IOException {
}
}

@Test
public void testDefaultNewGCMetricsIBMJ9() throws IOException {
try (final MisbehavingJMXServer server = new MisbehavingJMXServer.Builder().withJDKImage(
JDK_11_OPENJ9).appendJavaOpts("-Xgcpolicy:balanced").build()) {
final List<Map<String, Object>> actualMetrics = startAndGetMetrics(server, true);
assertThat(actualMetrics, hasSize(13));
final List<String> gcCycles = Arrays.asList(
"ZGC Major Cycles",
"ZGC Major Pauses");
assertGCMetric(actualMetrics, "jvm.gc.major_collection_count", gcCycles);
assertGCMetric(actualMetrics, "jvm.gc.major_collection_time", gcCycles);

final List<String> gcPauses = Arrays.asList(
"ZGC Minor Cycles",
"ZGC Minor Pauses");
assertGCMetric(actualMetrics, "jvm.gc.minor_collection_count", gcPauses);
assertGCMetric(actualMetrics, "jvm.gc.minor_collection_time", gcPauses);
}
}

private List<Map<String, Object>> startAndGetMetrics(final MisbehavingJMXServer server,
final boolean newGCMetrics) throws IOException {
server.start();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ public enum JDKImage {
BASE("base"),
JDK_11("eclipse-temurin:11"),
JDK_17("eclipse-temurin:17"),
JDK_21("eclipse-temurin:21");
JDK_21("eclipse-temurin:21"),
JDK_11_OPENJ9("adoptopenjdk/openjdk11-openj9:latest");

private final String image;

Expand Down

0 comments on commit 713eb16

Please sign in to comment.