mehakmeet commented on a change in pull request #1899: HADOOP-16914 Adding 
Output Stream Counters in ABFS
URL: https://github.com/apache/hadoop/pull/1899#discussion_r394230246
 
 

 ##########
 File path: 
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsOutputStream.java
 ##########
 @@ -0,0 +1,278 @@
+package org.apache.hadoop.fs.azurebfs;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.azurebfs.services.AbfsOutputStream;
+import org.apache.hadoop.fs.permission.FsPermission;
+
+/**
+ * Test AbfsOutputStream statistics.
+ */
+public class ITestAbfsOutputStream extends AbstractAbfsIntegrationTest {
+
+  public ITestAbfsOutputStream() throws Exception {
+  }
+
+  /**
+   * Tests to check bytes Uploading in {@link AbfsOutputStream}.
+   *
+   * @throws IOException
+   */
+  @Test
+  public void testAbfsOutputStreamUploadingBytes() throws IOException {
+    describe("Testing Bytes uploaded in AbfsOutputSteam");
+    final AzureBlobFileSystem fs = getFileSystem();
+    Path uploadBytesFilePath = new Path("AbfsOutputStreamStatsPath");
+    AzureBlobFileSystemStore abfss = fs.getAbfsStore();
+    FileSystem.Statistics statistics = fs.getFsStatistics();
+    abfss.getAbfsConfiguration().setDisableOutputStreamFlush(false);
+    String testBytesToUpload = "bytes";
+
+    AbfsOutputStream outForSomeBytes = null;
+    try {
+      outForSomeBytes = (AbfsOutputStream) 
abfss.createFile(uploadBytesFilePath,
+          statistics,
+          true,
+          FsPermission.getDefault(), FsPermission.getUMask(fs.getConf()));
+
+      //Test for zero bytes To upload
+      assertValues("bytes to upload", 0,
+          outForSomeBytes.getOutputStreamStatistics().bytesToUpload);
+
+      outForSomeBytes.write(testBytesToUpload.getBytes());
+      outForSomeBytes.flush();
+
+      //Test for some bytes to upload
+      assertValues("bytes to upload", testBytesToUpload.getBytes().length,
+          outForSomeBytes.getOutputStreamStatistics().bytesToUpload);
+
+      //Test for relation between bytesUploadSuccessful, bytesUploadFailed
+      // and bytesToUpload
+      assertValues("bytesUploadSuccessful equal to difference between "
+              + "bytesToUpload and bytesUploadFailed",
+          outForSomeBytes.getOutputStreamStatistics().bytesUploadSuccessful,
+          outForSomeBytes.getOutputStreamStatistics().bytesToUpload -
+              outForSomeBytes.getOutputStreamStatistics().bytesUploadFailed);
+
+    } finally {
+      if (outForSomeBytes != null) {
+        outForSomeBytes.close();
+      }
+    }
+
+    AbfsOutputStream outForLargeBytes = null;
+    try {
+      outForLargeBytes =
+          (AbfsOutputStream) abfss.createFile(uploadBytesFilePath,
+              statistics
+              , true, FsPermission.getDefault(),
+              FsPermission.getUMask(fs.getConf()));
+
+      int largeValue = 100000;
+      for (int i = 0; i < largeValue; i++) {
+        outForLargeBytes.write(testBytesToUpload.getBytes());
+      }
+      outForLargeBytes.flush();
+
+      //Test for large bytes to upload
+      assertValues("bytes to upload",
+          largeValue * (testBytesToUpload.getBytes().length),
+          outForLargeBytes.getOutputStreamStatistics().bytesToUpload);
+
+      //Test for relation between bytesUploadSuccessful, bytesUploadFailed
+      // and bytesToUpload
+      assertValues("bytesUploadSuccessful equal to difference between "
+              + "bytesToUpload and bytesUploadFailed",
+          outForSomeBytes.getOutputStreamStatistics().bytesUploadSuccessful,
+          outForSomeBytes.getOutputStreamStatistics().bytesToUpload -
+              outForSomeBytes.getOutputStreamStatistics().bytesUploadFailed);
+
+    } finally {
+      if (outForLargeBytes != null) {
+        outForLargeBytes.close();
+      }
+    }
+
+  }
+
+  /**
+   * Tests to check time spend on waiting for tasks to be complete on a
+   * blocking queue in {@link AbfsOutputStream}.
+   *
+   * @throws IOException
+   */
+  @Test
+  public void testAbfsOutputStreamTimeSpendOnWaitTask() throws IOException {
 
 Review comment:
   Need help on how to write tests for this counter.

----------------------------------------------------------------
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]

Reply via email to