From 93dedc07fbc9e0f98f8a0a6a35a7da0c568f1186 Mon Sep 17 00:00:00 2001 From: Varun <48163435+varunch77@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:49:46 -0500 Subject: [PATCH] Fix failing JMX tests (#426) * Extended agent run time from 2 to 5 minutes and set metrics_collection_interval to 60 seconds to better capture infrequent metrics (like jvm.gc.collections.elapsed and jvm.gc.collections.count) Some tests were failing because the average value of metrics fell slightly outside of the bounds (+/- 10%). I * Added java commands to enable the mbean registry to properly expose tomcat metrics * Upped error percentage to 15% from 10% --- test/metric/metric_validation_util.go | 2 +- .../agent_configs/jmx_tomcat_jvm_config.json | 3 ++- test/metric_value_benchmark/jmx_tomcat_jvm_test.go | 11 +++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/metric/metric_validation_util.go b/test/metric/metric_validation_util.go index 6e78d59a0..b1eba40a6 100644 --- a/test/metric/metric_validation_util.go +++ b/test/metric/metric_validation_util.go @@ -27,7 +27,7 @@ func IsAllValuesGreaterThanOrEqualToExpectedValue(metricName string, values []fl } totalSum += value } - metricErrorBound := 0.1 + metricErrorBound := 0.15 metricAverageValue := totalSum / float64(len(values)) upperBoundValue := expectedValue * (1 + metricErrorBound) lowerBoundValue := expectedValue * (1 - metricErrorBound) diff --git a/test/metric_value_benchmark/agent_configs/jmx_tomcat_jvm_config.json b/test/metric_value_benchmark/agent_configs/jmx_tomcat_jvm_config.json index fc2b09ac2..441023171 100644 --- a/test/metric_value_benchmark/agent_configs/jmx_tomcat_jvm_config.json +++ b/test/metric_value_benchmark/agent_configs/jmx_tomcat_jvm_config.json @@ -1,6 +1,7 @@ { "agent": { - "debug": true + "debug": true, + "metrics_collection_interval": 60 }, "metrics": { "namespace": "MetricValueBenchmarkJMXTest", diff --git a/test/metric_value_benchmark/jmx_tomcat_jvm_test.go b/test/metric_value_benchmark/jmx_tomcat_jvm_test.go index ad9e2758c..8597c043a 100644 --- a/test/metric_value_benchmark/jmx_tomcat_jvm_test.go +++ b/test/metric_value_benchmark/jmx_tomcat_jvm_test.go @@ -46,7 +46,7 @@ func (t *JMXTomcatJVMTestRunner) GetAgentConfigFileName() string { } func (t *JMXTomcatJVMTestRunner) GetAgentRunDuration() time.Duration { - return 2 * time.Minute + return 5 * time.Minute } func (t *JMXTomcatJVMTestRunner) SetupBeforeAgentRun() error { @@ -57,7 +57,14 @@ func (t *JMXTomcatJVMTestRunner) SetupBeforeAgentRun() error { log.Println("set up jvm and tomcat") startJMXCommands := []string{ - "nohup java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=2030 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=2030 -Dcom.sun.management.jmxremote.host=0.0.0.0 -Djava.rmi.server.hostname=0.0.0.0 -Dserver.port=8090 -Dspring.application.admin.enabled=true -jar jars/spring-boot-web-starter-tomcat.jar > /tmp/spring-boot-web-starter-tomcat-jar.txt 2>&1 &", + "nohup java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=2030 " + + "-Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false " + + "-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=2030 " + + "-Dcom.sun.management.jmxremote.host=0.0.0.0 -Djava.rmi.server.hostname=0.0.0.0 " + + "-Dserver.port=8090 -Dspring.application.admin.enabled=true " + + "-Dserver.tomcat.mbeanregistry.enabled=true -Dmanagement.endpoints.jmx.exposure.include=* " + + "-XX:+UseConcMarkSweepGC -verbose:gc " + + "-jar jars/spring-boot-web-starter-tomcat.jar > /tmp/spring-boot-web-starter-tomcat-jar.txt 2>&1 &", } err = common.RunCommands(startJMXCommands)