Skip to content

Conversation

@wzhallright
Copy link
Contributor

@wzhallright wzhallright commented Dec 21, 2023

What changes were proposed in this pull request?

Assertions in the form:

assertTrue(<x> == <y>)   
assertEquals(null, <x>) or assertTrue(<x> == null)
assertTrue(<x> != null)
assertEquals(<boolean>, <x>)

can be simplified to:

assertEquals(<x>, <y>)
assertNotNull(<x>)
assertTrue/assertFalse(<x>)
assertNull(<x>)

Not only are these simpler, some of them also provide more information in case of failure.

This PR updates such assertions in hadoop-ozone/integration-test.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-9955

CI

https://github.com/wzhallright/ozone/actions/runs/7284783456

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @wzhallright for the patch.

Comment on lines 264 to 266
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev1key));
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev2key));
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(fileKey));
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that TestOzoneFileInterfaces is being migrated to JUnit5 in #5838. The same changes are done in that PR, too. Please remove TestOzoneFileInterfaces from the patch to avoid conflicts.

}

assertTrue(leaderCount.size() == dnNum);
assertEquals(leaderCount.size(), dnNum);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also flip the arguments to match expected, actual order:

Suggested change
assertEquals(leaderCount.size(), dnNum);
assertEquals(dnNum, leaderCount.size());

assertEquals(leaderCount.size(), dnNum);
for (Map.Entry<UUID, Integer> entry: leaderCount.entrySet()) {
assertTrue(leaderCount.get(entry.getKey()) == leaderNumOfEachDn);
assertEquals(leaderCount.get(entry.getKey()), leaderNumOfEachDn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertEquals(leaderCount.get(entry.getKey()), leaderNumOfEachDn);
assertEquals(leaderNumOfEachDn, leaderCount.get(entry.getKey()));

latestVersionLocations.getBlocksLatestVersionOnly()
.forEach(omKeyLocationInfo ->
assertTrue(omKeyLocationInfo.getPartNumber() != -1));
assertNotEquals(omKeyLocationInfo.getPartNumber(), -1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertNotEquals(omKeyLocationInfo.getPartNumber(), -1));
assertNotEquals(-1, omKeyLocationInfo.getPartNumber()));

openKey.getKeyInfo().getLatestVersionLocations()
.getBlocksLatestVersionOnly();
assertTrue(locationInfoList.size() == 1);
assertEquals(locationInfoList.size(), 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertEquals(locationInfoList.size(), 1);
assertEquals(1, locationInfoList.size());

@wzhallright
Copy link
Contributor Author

@adoroszlai Thank you for your detailed comments and suggestions, has fixed the comments, PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants