-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-10208. Simplify tests using assertThrows in hadoop-hdds #6143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fapifta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the path @wzhallright the changes look good except that one change I left an inline comment on, can you please elaborate on that?
|
|
||
| @Test | ||
| public void testAddAndGetContainer() throws IOException, TimeoutException { | ||
| long containerID = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask what is the rationale behind changing this long to AtomicLong? The rest of the patch is really just changing exception testing to assertThrows, is it by chance a leftover from some other work, or intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it is changed to be able to use in this lambda expression:
Lines 322 to 325 in 482ec1a
| IOException e = | |
| assertThrows(IOException.class, | |
| () -> stateManager.addContainerToPipeline(finalPipeline.getId(), | |
| ContainerID.valueOf(containerID.incrementAndGet()))); |
I think it's fine. If we want to minimize the diff, we could keep long containerID and change the code above to something like this:
ContainerID cid = ContainerID.valueOf(++containerID);
IOException e = assertThrows(IOException.class,
() -> stateManager.addContainerToPipeline(finalPipeline.getId(), cid));There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review! the IntelliJ prompts me variable used in lambda expression should be final or effectively final, so i change long to AtomicLong. Perhaps there is a more elegant solution to this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adoroszlai That's a good idea. I will modify it. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the explanation, I did not catch that point. my bad.
|
Thanks @wzhallright for the patch, @fapifta for the review. |
What changes were proposed in this pull request?
Simplify tests using assertThrows in hadoop-hdds
What is the link to the Apache JIRA
HDDS-10208
CI
https://github.com/wzhallright/ozone/actions/runs/7737861963