use of org.apache.hadoop.fs.azure.AzureException in project hadoop by apache.
the class TestAzureFileSystemInstrumentation method testClientErrorMetrics.
@Test
public void testClientErrorMetrics() throws Exception {
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 {
outputStream.write(new byte[FILE_SIZE]);
outputStream.close();
assertTrue("Should've thrown", false);
} catch (AzureException ex) {
assertTrue("Unexpected exception: " + ex, ex.getMessage().contains("lease"));
}
assertEquals(1, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_CLIENT_ERRORS));
assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_SERVER_ERRORS));
} finally {
if (leaseID != null) {
testAccount.releaseLease(leaseID, fileName);
}
IOUtils.closeStream(outputStream);
}
}
Aggregations