You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/04/04 20:08:59 UTC
[GitHub] [geode] nonbinaryprogrammer opened a new pull request, #7551: GEODE-10216: Add test for existence of VM stats
nonbinaryprogrammer opened a new pull request, #7551:
URL: https://github.com/apache/geode/pull/7551
When we started running with JDK 11, some users noticed that a few stats
had gone missing. There was a one line fix in test.gradle, but the
change was not tested. This adds a test for the existence of the VM
stats so that none of the stats go missing in the future.
<!-- Thank you for submitting a contribution to Apache Geode. -->
<!-- In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
-->
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
- [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
- [ ] Is your initial contribution a single, squashed commit?
- [ ] Does `gradlew build` run cleanly?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
<!-- Note:
Please ensure that once the PR is submitted, check Concourse for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.
-->
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] nonbinaryprogrammer commented on a diff in pull request #7551: GEODE-10216: Add test for existence of VM stats
Posted by GitBox <gi...@apache.org>.
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] pivotal-jbarrett commented on a diff in pull request #7551: GEODE-10216: Add test for existence of VM stats
Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on code in PR #7551:
URL: https://github.com/apache/geode/pull/7551#discussion_r842219836
##########
geode-core/src/distributedTest/java/org/apache/geode/internal/statistics/StatisticsDistributedTest.java:
##########
@@ -490,6 +491,49 @@ 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());
Review Comment:
We should make sure the new test is at least written in AssertJ. If the effort to convert the other tests is small please consider that.
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] nonbinaryprogrammer commented on a diff in pull request #7551: GEODE-10216: Add test for existence of VM stats
Posted by GitBox <gi...@apache.org>.
nonbinaryprogrammer commented on code in PR #7551:
URL: https://github.com/apache/geode/pull/7551#discussion_r843145337
##########
geode-core/src/distributedTest/java/org/apache/geode/internal/statistics/StatisticsDistributedTest.java:
##########
@@ -490,6 +491,49 @@ 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());
Review Comment:
ah, defeated by copy-paste. gonna fix it all
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] nonbinaryprogrammer merged pull request #7551: GEODE-10216: Add test for existence of VM stats
Posted by GitBox <gi...@apache.org>.
nonbinaryprogrammer merged PR #7551:
URL: https://github.com/apache/geode/pull/7551
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] pivotal-jbarrett commented on a diff in pull request #7551: GEODE-10216: Add test for existence of VM stats
Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on code in PR #7551:
URL: https://github.com/apache/geode/pull/7551#discussion_r842135856
##########
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");
Review Comment:
What happens if the exception falls through rather than being caught, does that not have the same affect as failing the test?
##########
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:
I would love to see us shy away from the this style of testing where we catch exceptions and then `fail`. I prefer that we either let the exception be thrown, and that in itself fails the tests or AssertJ's `assertThatNoException().isThrownBy(() -> {something()})`.
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] pivotal-jbarrett commented on a diff in pull request #7551: GEODE-10216: Add test for existence of VM stats
Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on code in PR #7551:
URL: https://github.com/apache/geode/pull/7551#discussion_r843152204
##########
geode-core/src/distributedTest/java/org/apache/geode/internal/statistics/StatisticsDistributedTest.java:
##########
@@ -544,10 +584,12 @@ public static void main(final String[] args) throws Exception {
int value1 = reader.readIntStat(statType1, statName1);
int value2 = reader.readIntStat(statType2, statName2);
- assertTrue(statType1 + "#" + statName1 + "=" + value1 + " does not equal " + statType2 + "#"
- + statName2 + "=" + value2, value1 == value2);
+ assertThat(value1)
+ .as(statType1 + "#" + statName1 + "=" + value1 + " does not equal " + statType2 + "#"
+ + statName2 + "=" + value2)
+ .isEqualTo(value2);
} else {
- assertEquals("Minimum two args are required: statType statName", 2, args.length);
+ assertThat(args.length).as("Minimum two args are required: statType statName").isEqualTo(2);
Review Comment:
Isn't there an `assertThat(args)....hasSize(2)`
##########
geode-core/src/distributedTest/java/org/apache/geode/internal/statistics/StatisticsDistributedTest.java:
##########
@@ -749,24 +791,20 @@ int readIntStat(final String typeName, final String statName) throws IOException
if (dir.exists() && dir.isDirectory()) {
List<File> archives = findFilesWithSuffix(dir, regex, ".gfs");
return readIntStatFromArchives(archives, typeName, statName);
+ }
- // one archive file
- } else if (dir.exists() && dir.isFile()) {
- List<File> archives = new ArrayList<>();
- archives.add(dir);
- return readIntStatFromArchives(archives, typeName, statName);
+ assertThat(dir.exists() && dir.isFile()).as("archive file should exist").isTrue();
Review Comment:
There is a `assertThat(dir).isFile()` that satisfies both exists and is a file.
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org