HDDS-9982. Improve assertTrue assertions in hdds-server-framework#5862
HDDS-9982. Improve assertTrue assertions in hdds-server-framework#5862adoroszlai merged 3 commits intoapache:masterfrom
Conversation
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @wzhallright for working on this.
There was a problem hiding this comment.
assertFalse assertions can be changed along the same lines:
assertThat(result).doesNotContain(entry.getKey());
Sorry if that wasn't clear from the task description. I have now updated the parent issue.
There was a problem hiding this comment.
With assertTrue(..., message), the second parameter was only passed to get some useful hint in case of failure. When using assertThat, we get such hint automatically, so we can omit withFailMessage(message).
There was a problem hiding this comment.
Do we need to omit all waitFailMessage or allow the user to partially customize useful messages?
Because there is still some user-defined information in the current PR
There was a problem hiding this comment.
I'd remove two kinds:
- where the string itself is passed (like here)
- message similar to "expected: ..., got: ..."
We can keep the rest.
There was a problem hiding this comment.
Here the "not equal" value is changed from 0 to 1. Why?
There was a problem hiding this comment.
I think withFailMessage can be omitted here, too.
There was a problem hiding this comment.
nit: keeping .contains... on new line makes the assertion more readable, because assertThat's argument is also a chained method call
There was a problem hiding this comment.
This one can also be converted to assertThat.
|
Thanks @wzhallright for the patch. |
What changes were proposed in this pull request?
Improve assertTrue assertions in hadoop-hdds/framework
Assertions in the form:
do not provide any information about the actual value, if the assertion fails.
This can be improved by replacing them with:
which gives us more info in the form:
Similarly, assertions about inequality relations, e.g.:
can be replaced with:
The goal of this task is to find and replace such assertTrue assertions.
What is the link to the Apache JIRA
HDDS-9982
CI
https://github.com/wzhallright/ozone/actions/runs/7318537019