Skip to content

HDDS-10033. Improve assertTrue assertions in ozone-manager#5901

Merged
adoroszlai merged 3 commits intoapache:masterfrom
wzhallright:HDDS-10033
Jan 3, 2024
Merged

HDDS-10033. Improve assertTrue assertions in ozone-manager#5901
adoroszlai merged 3 commits intoapache:masterfrom
wzhallright:HDDS-10033

Conversation

@wzhallright
Copy link
Contributor

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

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 working on this. Mostly looks good. There is one failure, and some possibilities for improvement.

Comment on lines +637 to +638
assertThat(logCapturer.getOutput()).contains(
"for snapshot " + first.getName() + " already exists.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This one was assertFalse:

Suggested change
assertThat(logCapturer.getOutput()).contains(
"for snapshot " + first.getName() + " already exists.");
assertThat(logCapturer.getOutput()).doesNotContain(
"for snapshot " + first.getName() + " already exists.");

Comment on lines +518 to +520
assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnFour);
assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnFive);
assertThat(newBlockLocation.getPipeline().getNodes()).contains(dnSix);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we can check multiple items in a single call

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

Choose a reason for hiding this comment

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

nit:

Suggested change
.doesNotContain("CmdType " + cmdtype + " is not " + "categorized as readOnly or not.");
.doesNotContain("CmdType " + cmdtype + " is not categorized as readOnly or not.");

Comment on lines 810 to 811
assertInstanceOf(OMException.class, ex);
OMException omException = (OMException) ex;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: cast can be removed

Suggested change
assertInstanceOf(OMException.class, ex);
OMException omException = (OMException) ex;
OMException omException = assertInstanceOf(OMException.class, ex);

Comment on lines 286 to 288
assertInstanceOf(S3RevokeSecretResponse.class, omRevokeResponse);
S3RevokeSecretResponse s3RevokeSecretResponse =
(S3RevokeSecretResponse) omRevokeResponse;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: cast can be removed

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

Choose a reason for hiding this comment

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

nit: this can be replaced, too. This way test failure shows list contents if it is found not empty.

Suggested change
assertTrue(jobList.isEmpty());
assertThat(jobList).isEmpty();

@adoroszlai adoroszlai added the test label Jan 2, 2024
@wzhallright
Copy link
Contributor Author

@adoroszlai Thanks for your review. Comments have been fixed, please check.

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 updating the patch.

@adoroszlai adoroszlai merged commit b9e74f6 into apache:master Jan 3, 2024
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