|
@@ -153,8 +153,8 @@ public class TestFsck {
|
|
|
String outStr = runFsck(conf, 0, true, "/");
|
|
|
verifyAuditLogs();
|
|
|
assertEquals(aTime, fs.getFileStatus(file).getAccessTime());
|
|
|
- assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
|
|
|
System.out.println(outStr);
|
|
|
+ assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
|
|
|
if (fs != null) {try{fs.close();} catch(Exception e){}}
|
|
|
cluster.shutdown();
|
|
|
|
|
@@ -194,18 +194,30 @@ public class TestFsck {
|
|
|
// Turn off the logs
|
|
|
Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
|
|
|
logger.setLevel(Level.OFF);
|
|
|
-
|
|
|
- // Audit log should contain one getfileinfo and one fsck
|
|
|
- BufferedReader reader = new BufferedReader(new FileReader(auditLogFile));
|
|
|
- String line = reader.readLine();
|
|
|
- assertNotNull(line);
|
|
|
- assertTrue("Expected getfileinfo event not found in audit log",
|
|
|
- getfileinfoPattern.matcher(line).matches());
|
|
|
- line = reader.readLine();
|
|
|
- assertNotNull(line);
|
|
|
- assertTrue("Expected fsck event not found in audit log",
|
|
|
- fsckPattern.matcher(line).matches());
|
|
|
- assertNull("Unexpected event in audit log", reader.readLine());
|
|
|
+
|
|
|
+ BufferedReader reader = null;
|
|
|
+ try {
|
|
|
+ // Audit log should contain one getfileinfo and one fsck
|
|
|
+ reader = new BufferedReader(new FileReader(auditLogFile));
|
|
|
+ String line = reader.readLine();
|
|
|
+ assertNotNull(line);
|
|
|
+ assertTrue("Expected getfileinfo event not found in audit log",
|
|
|
+ getfileinfoPattern.matcher(line).matches());
|
|
|
+ line = reader.readLine();
|
|
|
+ assertNotNull(line);
|
|
|
+ assertTrue("Expected fsck event not found in audit log", fsckPattern
|
|
|
+ .matcher(line).matches());
|
|
|
+ assertNull("Unexpected event in audit log", reader.readLine());
|
|
|
+ } finally {
|
|
|
+ // Close the reader and remove the appender to release the audit log file
|
|
|
+ // handle after verifying the content of the file.
|
|
|
+ if (reader != null) {
|
|
|
+ reader.close();
|
|
|
+ }
|
|
|
+ if (logger != null) {
|
|
|
+ logger.removeAllAppenders();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -963,9 +975,9 @@ public class TestFsck {
|
|
|
String outStr = runFsck(conf, 0, true, "/");
|
|
|
verifyAuditLogs();
|
|
|
assertEquals(aTime, fc.getFileStatus(symlink).getAccessTime());
|
|
|
- assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
|
|
|
- assertTrue(outStr.contains("Total symlinks:\t\t1\n"));
|
|
|
System.out.println(outStr);
|
|
|
+ assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
|
|
|
+ assertTrue(outStr.contains("Total symlinks:\t\t1"));
|
|
|
util.cleanup(fs, fileName);
|
|
|
} finally {
|
|
|
if (fs != null) {try{fs.close();} catch(Exception e){}}
|