HDDS-10033. Improve assertTrue assertions in ozone-manager#5901
HDDS-10033. Improve assertTrue assertions in ozone-manager#5901adoroszlai merged 3 commits intoapache:masterfrom
Conversation
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @wzhallright for working on this. Mostly looks good. There is one failure, and some possibilities for improvement.
| assertThat(logCapturer.getOutput()).contains( | ||
| "for snapshot " + first.getName() + " already exists."); |
There was a problem hiding this comment.
This one was assertFalse:
| assertThat(logCapturer.getOutput()).contains( | |
| "for snapshot " + first.getName() + " already exists."); | |
| assertThat(logCapturer.getOutput()).doesNotContain( | |
| "for snapshot " + first.getName() + " already exists."); |
| assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnFour); | ||
| assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnFive); | ||
| assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnSix); |
There was a problem hiding this comment.
nit: we can check multiple items in a single call
| assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnFour); | |
| assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnFive); | |
| assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnSix); | |
| assertThat(newBlockLocation.getPipeline().getNodes()) | |
| .contains(dnFour, dnFive, dnSix); |
| cmdtype + " is not categorized in OmUtils#isReadyOnly"); | ||
| assertThat(logCapturer.getOutput()) | ||
| .withFailMessage(cmdtype + " is not categorized in OmUtils#isReadyOnly") | ||
| .doesNotContain("CmdType " + cmdtype + " is not " + "categorized as readOnly or not."); |
There was a problem hiding this comment.
nit:
| .doesNotContain("CmdType " + cmdtype + " is not " + "categorized as readOnly or not."); | |
| .doesNotContain("CmdType " + cmdtype + " is not categorized as readOnly or not."); |
| assertInstanceOf(OMException.class, ex); | ||
| OMException omException = (OMException) ex; |
There was a problem hiding this comment.
nit: cast can be removed
| assertInstanceOf(OMException.class, ex); | |
| OMException omException = (OMException) ex; | |
| OMException omException = assertInstanceOf(OMException.class, ex); |
| assertInstanceOf(S3RevokeSecretResponse.class, omRevokeResponse); | ||
| S3RevokeSecretResponse s3RevokeSecretResponse = | ||
| (S3RevokeSecretResponse) omRevokeResponse; |
There was a problem hiding this comment.
nit: cast can be removed
| assertInstanceOf(S3RevokeSecretResponse.class, omRevokeResponse); | |
| S3RevokeSecretResponse s3RevokeSecretResponse = | |
| (S3RevokeSecretResponse) omRevokeResponse; | |
| S3RevokeSecretResponse s3RevokeSecretResponse = | |
| assertInstanceOf(S3RevokeSecretResponse.class, omRevokeResponse); |
(Also in other test cases in this class.)
| assertTrue(jobList.contains(diffJob)); | ||
| assertThat(jobList).contains(diffJob); | ||
| } else { | ||
| assertTrue(jobList.isEmpty()); |
There was a problem hiding this comment.
nit: this can be replaced, too. This way test failure shows list contents if it is found not empty.
| assertTrue(jobList.isEmpty()); | |
| assertThat(jobList).isEmpty(); |
|
@adoroszlai Thanks for your review. Comments have been fixed, please check. |
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @wzhallright for updating the patch.
What changes were proposed in this pull request?
Improve assertTrue/assertFalse assertions in hadoop-ozone/ozone-manager
(see parent task HDDS-9951 for details)
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-10033
CI
https://github.com/wzhallright/ozone/actions/runs/7382711143