mehakmeet commented on a change in pull request #1881: HADOOP-16910 Adding file
system counters in ABFS
URL: https://github.com/apache/hadoop/pull/1881#discussion_r390493936
##########
File path:
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java
##########
@@ -59,6 +62,59 @@ public void testEnsureFileCreatedImmediately() throws
Exception {
assertIsFile(fs, TEST_FILE_PATH);
}
+ /**
+ * {@link AbfsOutputStream#incrementWriteOps()}
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWriteOpsMetric() throws Exception {
+ describe("Test to see correct population of write operations in Abfs");
+ final AzureBlobFileSystem fs = getFileSystem();
+ Path smallFile = new Path("testOneCall");
+ Path largeFile = new Path("testLargeCalls");
+ String testWriteOps = "test";
+ FileSystem.Statistics statistics = fs.getFsStatistics();
+ statistics.reset();
+
+ //Test for zero write operation
+ Assert.assertEquals(0, statistics.getWriteOps());
+
+ FSDataOutputStream outForOneCall = fs.create(smallFile);
+ statistics.reset();
+ //Writing "test" 1 time
+ outForOneCall
+ .write(testWriteOps.getBytes(), 0, testWriteOps.getBytes().length);
+
+ //Test for one write operation
+ Assert.assertEquals(1, statistics.getWriteOps());
+
+ outForOneCall.close();
+ //validating Content of file
+ Assert.assertEquals(true, validateContent(fs, smallFile,
+ testWriteOps.getBytes()));
+
+ String largeFileValidationString = "";
+ FSDataOutputStream outForLargeCalls = fs.create(largeFile);
+ statistics.reset();
+ //Writing "test" 1000 times
+ for (int i = 0; i < 1000; i++) {
+ outForLargeCalls.write(testWriteOps.getBytes(), 0,
+ testWriteOps.getBytes().length);
+
+ //Creating Validation string of "test" 1000 times
+ largeFileValidationString += testWriteOps;
Review comment:
Will be using StringBuilder here and use append() istead of += for String
concatenation.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]