[
https://issues.apache.org/jira/browse/HDDS-1886?focusedWorklogId=286734&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-286734
]
ASF GitHub Bot logged work on HDDS-1886:
----------------------------------------
Author: ASF GitHub Bot
Created on: 01/Aug/19 14:23
Start Date: 01/Aug/19 14:23
Worklog Time Spent: 10m
Work Description: dineshchitlangia commented on pull request #1205:
HDDS-1886. Use ArrayList#clear to address audit failure scenario
URL: https://github.com/apache/hadoop/pull/1205#discussion_r309700845
##########
File path:
hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/audit/TestOzoneAuditLogger.java
##########
@@ -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();
Review comment:
@adoroszlai Thanks for review & suggestions.
> 1. Wrap assertions and cleanup in `try` and `finally`, 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.
> 2. Make `verifyLog` accept `String...` 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.
> 3. 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.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 286734)
Time Spent: 50m (was: 40m)
> Use ArrayList#clear to address audit failure scenario
> -----------------------------------------------------
>
> Key: HDDS-1886
> URL: https://issues.apache.org/jira/browse/HDDS-1886
> Project: Hadoop Distributed Data Store
> Issue Type: Test
> Components: test
> Reporter: Dinesh Chitlangia
> Assignee: Dinesh Chitlangia
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 50m
> Remaining Estimate: 0h
>
> TestOzoneAuditLogger makes use of ArrayList#remove to clear the log file in
> between test runs.
> When writing tests in future for more failures scenarios, the tests will fail
> if the log entry has multi-line stack trace in audit logs.
> This jira aims to use ArrayList#clear to make the test future proof.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]