HADOOP-12540. TestAzureFileSystemInstrumentation#testClientErrorMetrics fails intermittently due to assumption that a lease error will be thrown. Contributed by Gaurav Kanade.
This commit is contained in:
parent
e2a5441b06
commit
0fb1867fd6
@ -1320,6 +1320,10 @@ Release 2.8.0 - UNRELEASED
|
||||
|
||||
HADOOP-12542. TestDNS fails on Windows after HADOOP-12437. (cnauroth)
|
||||
|
||||
HADOOP-12540. TestAzureFileSystemInstrumentation#testClientErrorMetrics
|
||||
fails intermittently due to assumption that a lease error will be thrown.
|
||||
(Gaurav Kanade via cnauroth)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
|
||||
|
@ -48,6 +48,7 @@
|
||||
import org.apache.hadoop.fs.azure.AzureException;
|
||||
import org.apache.hadoop.fs.azure.AzureNativeFileSystemStore;
|
||||
import org.apache.hadoop.fs.azure.NativeAzureFileSystem;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||
import org.apache.hadoop.metrics2.MetricsTag;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
@ -405,14 +406,19 @@ public void testMetricsOnDirRename() throws Exception {
|
||||
|
||||
@Test
|
||||
public void testClientErrorMetrics() throws Exception {
|
||||
String directoryName = "metricsTestDirectory_ClientError";
|
||||
Path directoryPath = new Path("/" + directoryName);
|
||||
assertTrue(fs.mkdirs(directoryPath));
|
||||
String leaseID = testAccount.acquireShortLease(directoryName);
|
||||
String fileName = "metricsTestFile_ClientError";
|
||||
Path filePath = new Path("/"+fileName);
|
||||
final int FILE_SIZE = 100;
|
||||
OutputStream outputStream = null;
|
||||
String leaseID = null;
|
||||
try {
|
||||
// Create a file
|
||||
outputStream = fs.create(filePath);
|
||||
leaseID = testAccount.acquireShortLease(fileName);
|
||||
try {
|
||||
fs.delete(directoryPath, true);
|
||||
assertTrue("Should've thrown.", false);
|
||||
outputStream.write(new byte[FILE_SIZE]);
|
||||
outputStream.close();
|
||||
assertTrue("Should've thrown", false);
|
||||
} catch (AzureException ex) {
|
||||
assertTrue("Unexpected exception: " + ex,
|
||||
ex.getMessage().contains("lease"));
|
||||
@ -420,7 +426,10 @@ public void testClientErrorMetrics() throws Exception {
|
||||
assertEquals(1, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_CLIENT_ERRORS));
|
||||
assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_SERVER_ERRORS));
|
||||
} finally {
|
||||
testAccount.releaseLease(leaseID, directoryName);
|
||||
if(leaseID != null){
|
||||
testAccount.releaseLease(leaseID, fileName);
|
||||
}
|
||||
IOUtils.closeStream(outputStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user