Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMLII-1952] Adding some unit tests for IBM J9 GC #535

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading