Skip to content

Commit

Permalink
Fix failing JMX tests (#426)
Browse files Browse the repository at this point in the history
* 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%
  • Loading branch information
varunch77 authored Nov 14, 2024
1 parent c0aafbb commit 93dedc0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/metric/metric_validation_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"agent": {
"debug": true
"debug": true,
"metrics_collection_interval": 60
},
"metrics": {
"namespace": "MetricValueBenchmarkJMXTest",
Expand Down
11 changes: 9 additions & 2 deletions test/metric_value_benchmark/jmx_tomcat_jvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit 93dedc0

Please sign in to comment.