-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDDS-1886. Use ArrayList#clear to address audit failure scenario #1205
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
/label ozone |
@@ -153,7 +153,7 @@ private void verifyLog(String expected) throws IOException { | |||
assertTrue(lines.size() != 0); | |||
assertTrue(expected.equalsIgnoreCase(lines.get(0))); | |||
//empty the file | |||
lines.remove(0); | |||
lines.clear(); |
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.
@dineshchitlangia good idea to avoid unnecessary assumptions.
Here are some further suggestions:
- Wrap assertions and cleanup in
try
andfinally
, respectively. Otherwise a failed assertion would cause all further independent test cases to also fail due to leftover content in the file. (This one is not specific to multi-line cases.) - Make
verifyLog
acceptString...
and check each expected line. Also, retry reading the file until it has enough lines instead of being non-empty. - I think using
assertEquals
would make it easier to spot differences between expected and actual values. (I'm not sure case-ignorance is really important. Currently the test passes with strict case check, too.)
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 Thanks for review & suggestions.
- Wrap assertions and cleanup in
try
andfinally
, respectively. Otherwise a failed assertion would cause all further independent test cases to also fail due to leftover content in the file. (This one is not specific to multi-line cases.)
Yes, that was the original approach, however, the review at the time preferred to throw the Exception instead of catching it. This is because we won't accept a few failures, the criteria required is all tests must pass.
- Make
verifyLog
acceptString...
and check each expected line. Also, retry reading the file until it has enough lines instead of being non-empty.
In this test for the base framework of audit logging, we invoke verifyLog each time a log worthy event has occurred. So at any time, the recent event is the only event in the audit log. Hence we verify only one line at a time as they are invoked by different tests.
- I think using
assertEquals
would make it easier to spot differences between expected and actual values. (I'm not sure case-ignorance is really important. Currently the test passes with strict case check, too.)
Again, since the test was for base audit logging framework, strict checking was required in the original.
That said, the goal of current jira is only to move away from using ArrayList#remove.
I have filed HDDS-1889 to address the multi-line log scenario that will cover your suggestions.
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 Could please you let me know if there are any other concerns based on my response above and follow up jira? 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.
@dineshchitlangia Thanks for clarifying the scope and filing the follow-up Jira. I don't have any other concerns.
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 Thanks for the review. I will commit this now.
Checkstyle & Integrations failures are unrelated to the patch |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
No description provided.