Skip to content

GEODE-10216: Add test for existence of VM stats#7551

Merged
nonbinaryprogrammer merged 3 commits intoapache:developfrom
nonbinaryprogrammer:GEODE-10216-Missing-Stats
Apr 6, 2022
Merged

GEODE-10216: Add test for existence of VM stats#7551
nonbinaryprogrammer merged 3 commits intoapache:developfrom
nonbinaryprogrammer:GEODE-10216-Missing-Stats

Conversation

@nonbinaryprogrammer
Copy link
Contributor

@nonbinaryprogrammer nonbinaryprogrammer commented Apr 4, 2022

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 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?

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.
vmStats.get("fdsOpen");
vmStats.get("fdLimit");
} catch (IllegalArgumentException e) {
fail("Stats do not exist: " + e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()}).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

.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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a assertThat(dir).isFile() that satisfies both exists and is a file.

@nonbinaryprogrammer nonbinaryprogrammer merged commit de91e33 into apache:develop Apr 6, 2022
@nonbinaryprogrammer nonbinaryprogrammer deleted the GEODE-10216-Missing-Stats branch April 6, 2022 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants