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 313fd89
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 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,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<Map<String, Object>> 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<Map<String, Object>> 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<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 313fd89

Please sign in to comment.