HDFS-10463. TestRollingFileSystemSinkWithHdfs needs some cleanup. (Daniel Templeton via kasha)
This commit is contained in:
parent
72773f8ea8
commit
b4c8729cf9
|
@ -221,8 +221,12 @@ public class RollingFileSystemSinkTestBase {
|
|||
mm1.testMetric2.incr(2);
|
||||
|
||||
ms.publishMetricsNow(); // publish the metrics
|
||||
|
||||
try {
|
||||
ms.stop();
|
||||
} finally {
|
||||
ms.shutdown();
|
||||
}
|
||||
|
||||
return readLogFile(path, then, count);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public class TestRollingFileSystemSinkWithHdfs
|
|||
public void testSilentAppend() throws Exception {
|
||||
String path = "hdfs://" + cluster.getNameNode().getHostAndPort() + "/tmp";
|
||||
|
||||
assertExtraContents(doAppendTest(path, false, true, 1));
|
||||
assertExtraContents(doAppendTest(path, true, true, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,9 +159,12 @@ public class TestRollingFileSystemSinkWithHdfs
|
|||
assertTrue("No exception was generated while writing metrics "
|
||||
+ "even though HDFS was unavailable", MockSink.errored);
|
||||
|
||||
try {
|
||||
ms.stop();
|
||||
} finally {
|
||||
ms.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that closing a file in HDFS fails when HDFS is unavailable.
|
||||
|
@ -183,14 +186,15 @@ public class TestRollingFileSystemSinkWithHdfs
|
|||
|
||||
try {
|
||||
ms.stop();
|
||||
|
||||
fail("No exception was generated while stopping sink "
|
||||
+ "even though HDFS was unavailable");
|
||||
} catch (MetricsException ex) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
} finally {
|
||||
ms.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that writing to HDFS fails silently when HDFS is unavailable.
|
||||
|
@ -215,9 +219,12 @@ public class TestRollingFileSystemSinkWithHdfs
|
|||
+ "while HDFS was unavailable, even though the sink is set to "
|
||||
+ "ignore errors", MockSink.errored);
|
||||
|
||||
try {
|
||||
ms.stop();
|
||||
} finally {
|
||||
ms.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that closing a file in HDFS silently fails when HDFS is unavailable.
|
||||
|
@ -237,14 +244,16 @@ public class TestRollingFileSystemSinkWithHdfs
|
|||
shutdownHdfs();
|
||||
MockSink.errored = false;
|
||||
|
||||
try {
|
||||
ms.stop();
|
||||
|
||||
assertFalse("An exception was generated stopping sink "
|
||||
+ "while HDFS was unavailable, even though the sink is set to "
|
||||
+ "ignore errors", MockSink.errored);
|
||||
|
||||
} finally {
|
||||
ms.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test specifically checks whether the flusher thread is automatically
|
||||
|
@ -272,6 +281,7 @@ public class TestRollingFileSystemSinkWithHdfs
|
|||
|
||||
int count = 0;
|
||||
|
||||
try {
|
||||
// Sleep until the flusher has run. This should never actually need to
|
||||
// sleep, but the sleep is here to make sure this test isn't flakey.
|
||||
while (!RollingFileSystemSink.hasFlushed) {
|
||||
|
@ -293,8 +303,15 @@ public class TestRollingFileSystemSinkWithHdfs
|
|||
assertTrue("The flusher thread didn't flush the log contents. Expected "
|
||||
+ "at least 236 bytes in the log file, but got " + status.getLen(),
|
||||
status.getLen() >= 236);
|
||||
} finally {
|
||||
RollingFileSystemSink.forceFlush = false;
|
||||
|
||||
try {
|
||||
ms.stop();
|
||||
} finally {
|
||||
ms.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue