From b95cef97bdab2508cb3027e647bc5c7b79130a1f Mon Sep 17 00:00:00 2001 From: Carlos Roman Date: Wed, 7 Aug 2024 12:38:55 +0100 Subject: [PATCH] Adding unit test for IBM G9 GC metrics --- .../org/datadog/jmxfetch/TestGCMetrics.java | 34 +++++++++++++++++++ .../jmxfetch/util/server/JDKImage.java | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java b/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java index 7d1973ddb..a180c35ed 100644 --- a/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java +++ b/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java @@ -148,6 +148,40 @@ public void testDefaultNewGCMetricsUseGenerationalZGC() throws IOException { } } + @Test + public void testDefaultNewGCMetricsIBMJ9Balanced() throws IOException { + try (final MisbehavingJMXServer server = new MisbehavingJMXServer.Builder().withJDKImage( + JDK_11_OPENJ9).appendJavaOpts("-Xgcpolicy:balanced").build()) { + final List> actualMetrics = startAndGetMetrics(server, true); + assertThat(actualMetrics, hasSize(13)); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_count", "partial gc", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_time", "partial gc", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_count", "global garbage collect", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_time", "global garbage collect", "counter"); + } + } + + @Test + public void testDefaultNewGCMetricsIBMJ9Gencon() throws IOException { + try (final MisbehavingJMXServer server = new MisbehavingJMXServer.Builder().withJDKImage( + JDK_11_OPENJ9).appendJavaOpts("-Xgcpolicy:gencon").build()) { + final List> actualMetrics = startAndGetMetrics(server, true); + assertThat(actualMetrics, hasSize(13)); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_count", "scavenge", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.minor_collection_time", "scavenge", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_count", "global", "counter"); + assertGCMetric(actualMetrics, + "jvm.gc.major_collection_time", "global", "counter"); + } + } + private List> startAndGetMetrics(final MisbehavingJMXServer server, final boolean newGCMetrics) throws IOException { server.start(); diff --git a/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java b/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java index 365f7bd5b..19775b772 100644 --- a/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java +++ b/src/test/java/org/datadog/jmxfetch/util/server/JDKImage.java @@ -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;