nonbinaryprogrammer commented on code in PR #7551:
URL: https://github.com/apache/geode/pull/7551#discussion_r842176410


##########
geode-core/src/distributedTest/java/org/apache/geode/internal/statistics/StatisticsDistributedTest.java:
##########
@@ -490,6 +490,53 @@ public void testPubAndSubCustomStats() throws Exception {
         combinedUpdateEvents == combinedPuts);
   }
 
+  @Test
+  public void testExistenceOfVMStats() {
+    String regionName = "region_1";
+    VM vm = getHost(0).getVM(0);
+
+    vm.invoke(() -> {
+      Properties props = new Properties();
+      props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
+      props.setProperty(STATISTIC_SAMPLE_RATE, "1000");
+
+      InternalDistributedSystem system = getSystem(props);
+
+      // assert that sampler is working as expected
+      GemFireStatSampler sampler = system.getStatSampler();
+      assertTrue(sampler.isSamplingEnabled());
+      assertTrue(sampler.isAlive());
+
+      await("awaiting SampleCollector to exist")
+          .until(() -> sampler.getSampleCollector() != null);
+
+      SampleCollector sampleCollector = sampler.getSampleCollector();
+      assertNotNull(sampleCollector);
+
+      StatisticsType VMStatsType = getSystem().findType("VMStats");
+      Statistics vmStats = getSystem().findStatisticsByType(VMStatsType)[0];
+
+      try {
+        vmStats.get("pendingFinalization");
+        vmStats.get("loadedClasses");
+        vmStats.get("unloadedClasses");
+        vmStats.get("daemonThreads");
+        vmStats.get("peakThreads");
+        vmStats.get("threads");
+        vmStats.get("threadStarts");
+        vmStats.get("cpus");
+        vmStats.get("freeMemory");
+        vmStats.get("totalMemory");
+        vmStats.get("maxMemory");
+        vmStats.get("processCpuTime");
+        vmStats.get("fdsOpen");
+        vmStats.get("fdLimit");
+      } catch (IllegalArgumentException e) {
+        fail("Stats do not exist: " + e.getMessage());

Review Comment:
   thank you! I was trying to use `assertThatThrownBy(() -> 
something).doesNotThrow()` and it was failing when the stat exists/no exception 
is thrown



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to