Skip to content

Commit 3cfab5d

Browse files
authored
Merge pull request #27023 from pgunapal/26998-fixMPMetricsFAT
Added a wait to Computed MPMetrics FAT to ensure ServletStats MBean are registered before calling /metrics
2 parents 4afe738 + 229363e commit 3cfab5d

File tree

3 files changed

+15
-0
lines changed
  • dev
    • io.openliberty.microprofile.metrics.internal.3.x.monitor_fat/fat/src/io/openliberty/microprofile/metrics/internal/monitor_fat
    • io.openliberty.microprofile.metrics.internal.4.x.monitor_fat/fat/src/io/openliberty/microprofile/metrics/internal/monitor_fat
    • io.openliberty.microprofile.metrics.internal.5.x.monitor_fat/fat/src/io/openliberty/microprofile/metrics/internal/monitor_fat

3 files changed

+15
-0
lines changed

dev/io.openliberty.microprofile.metrics.internal.3.x.monitor_fat/fat/src/io/openliberty/microprofile/metrics/internal/monitor_fat/ComputedMetricsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,12 @@ public void testDynamicApplicationStopWithMpConfigPropSet() throws Exception {
532532

533533
Log.info(c, testName, "------- Hitting the testREST application endpoint to initialize the REST metrics ------");
534534
getHttpServlet("/testRESTApp/test/get", computedMetricsServer);
535+
536+
Log.info(c, testName, "------- Wait for the Servlet MBean for the REST test app to get registered in MonitorMetrics, before hitting the /metrics endpoint ------");
537+
String mbeanRegStr = computedMetricsServer.waitForStringInLogUsingMark("type=ServletStats,name=testRESTApp.io.openliberty.microprofile.metrics.internal.monitor_fat.rest.TestApplication is registered", 60000, computedMetricsServer.getMostRecentTraceFile());
535538

539+
Log.info(c, testName, "------- Found Servlet MBean for the REST test app successfully registered trace : " + mbeanRegStr);
540+
536541
Log.info(c, testName, "------- Make sure all the expected metrics have the \"_app=myserver\" tag ------");
537542
checkForExpectedStrings(getHttpsServlet("/metrics/vendor", computedMetricsServer), expectedMetrics);
538543

dev/io.openliberty.microprofile.metrics.internal.4.x.monitor_fat/fat/src/io/openliberty/microprofile/metrics/internal/monitor_fat/ComputedMetricsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ public void testDynamicApplicationStopWithMpConfigPropSet() throws Exception {
533533
Log.info(c, testName, "------- Hitting the testREST application endpoint to initialize the REST metrics ------");
534534
getHttpServlet("/testRESTApp/test/get", computedMetricsServer);
535535

536+
Log.info(c, testName, "------- Wait for the Servlet MBean for the REST test app to get registered in MonitorMetrics, before hitting the /metrics endpoint ------");
537+
String mbeanRegStr = computedMetricsServer.waitForStringInLogUsingMark("type=ServletStats,name=testRESTApp.io.openliberty.microprofile.metrics.internal.monitor_fat.rest.TestApplication is registered", 60000, computedMetricsServer.getMostRecentTraceFile());
538+
539+
Log.info(c, testName, "------- Found Servlet MBean for the REST test app successfully registered trace : " + mbeanRegStr);
540+
536541
Log.info(c, testName, "------- Make sure all the expected metrics have the \"_app=myserver\" tag ------");
537542
checkForExpectedStrings(getHttpsServlet("/metrics/vendor", computedMetricsServer), expectedMetrics);
538543

dev/io.openliberty.microprofile.metrics.internal.5.x.monitor_fat/fat/src/io/openliberty/microprofile/metrics/internal/monitor_fat/ComputedMetricsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ public void testDynamicApplicationStopWithMpConfigPropSet() throws Exception {
582582
Log.info(c, testName, "------- Hitting the testREST application endpoint to initialize the REST metrics ------");
583583
getHttpServlet("/testRESTApp/test/get", computedMetricsServer);
584584

585+
Log.info(c, testName, "------- Wait for the Servlet MBean for the REST test app to get registered in MonitorMetrics, before hitting the /metrics endpoint ------");
586+
String mbeanRegStr = computedMetricsServer.waitForStringInLogUsingMark("type=ServletStats,name=testRESTApp.io.openliberty.microprofile.metrics.internal.monitor_fat.rest.TestApplication is registered", 60000, computedMetricsServer.getMostRecentTraceFile());
587+
588+
Log.info(c, testName, "------- Found Servlet MBean for the REST test app successfully registered trace : " + mbeanRegStr);
589+
585590
Log.info(c, testName, "------- Make sure all the expected metrics have the \"mp_app=myserver\" tag ------");
586591
checkForExpectedStrings(getHttpsServlet("/metrics?scope=vendor", computedMetricsServer), expectedMetrics);
587592

0 commit comments

Comments
 (0)