GEODE-10216: Add test for existence of VM stats#7551
Merged
nonbinaryprogrammer merged 3 commits intoapache:developfrom Apr 6, 2022
Merged
GEODE-10216: Add test for existence of VM stats#7551nonbinaryprogrammer merged 3 commits intoapache:developfrom
nonbinaryprogrammer merged 3 commits intoapache:developfrom
Conversation
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.
jake-at-work
approved these changes
Apr 4, 2022
...src/distributedTest/java/org/apache/geode/internal/statistics/StatisticsDistributedTest.java
Outdated
Show resolved
Hide resolved
| vmStats.get("fdsOpen"); | ||
| vmStats.get("fdLimit"); | ||
| } catch (IllegalArgumentException e) { | ||
| fail("Stats do not exist: " + e.getMessage()); |
Contributor
There was a problem hiding this 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()}).
Contributor
Author
There was a problem hiding this comment.
thank you! I was trying to use assertThatThrownBy(() -> something).doesNotThrow() and it was failing when the stat exists/no exception is thrown
jake-at-work
requested changes
Apr 4, 2022
...src/distributedTest/java/org/apache/geode/internal/statistics/StatisticsDistributedTest.java
Outdated
Show resolved
Hide resolved
jake-at-work
approved these changes
Apr 5, 2022
| .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); |
Contributor
There was a problem hiding this comment.
Isn't there an assertThat(args)....hasSize(2)
| List<File> archives = new ArrayList<>(); | ||
| archives.add(dir); | ||
| return readIntStatFromArchives(archives, typeName, statName); | ||
| assertThat(dir.exists() && dir.isFile()).as("archive file should exist").isTrue(); |
Contributor
There was a problem hiding this comment.
There is a assertThat(dir).isFile() that satisfies both exists and is a file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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 buildrun 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?