mehakmeet commented on a change in pull request #1991:
URL: https://github.com/apache/hadoop/pull/1991#discussion_r418149950



##########
File path: 
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAbfsStatistics.java
##########
@@ -0,0 +1,309 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs.azurebfs;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.junit.Test;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+
+/**
+ * Tests AzureBlobFileSystem Statistics.
+ */
+public class ITestAbfsStatistics extends AbstractAbfsIntegrationTest {
+
+  private static final int NUMBER_OF_OPS = 10;
+
+  public ITestAbfsStatistics() throws Exception {
+  }
+
+  /**
+   * Testing statistics by creating files and directories.
+   */
+  @Test
+  public void testCreateStatistics() throws IOException {
+    describe("Testing counter values got by creating directories and files in"
+        + " Abfs");
+
+    AzureBlobFileSystem fs = getFileSystem();
+    Path createFilePath = path(getMethodName());
+    Path createDirectoryPath = path(getMethodName() + "Dir");
+
+    Map<String, Long> metricMap = fs.getInstrumentation().toMap();
+
+    /*
+     Test for initial values of create statistics ; getFileStatus is called
+     1 time after Abfs initialisation.
+     */
+    assertEquals("Mismatch in op_create", 0,
+        (long) metricMap.get("op_create"));
+    assertEquals("Mismatch in op_create_non_recursive", 0,
+        (long) metricMap.get("op_create_non_recursive"));
+    assertEquals("Mismatch in files_created", 0,
+        (long) metricMap.get("files_created"));
+    assertEquals("Mismatch in directories_created", 0,
+        (long) metricMap.get("directories_created"));
+    assertEquals("Mismatch in op_mkdirs", 0,
+        (long) metricMap.get("op_mkdirs"));
+    assertEquals("Mismatch in op_get_file_status", 1,
+        (long) metricMap.get("op_get_file_status"));
+
+    try {
+
+      fs.mkdirs(createDirectoryPath);
+      fs.createNonRecursive(createFilePath, FsPermission
+          .getDefault(), false, 1024, (short) 1, 1024, null);
+
+      metricMap = fs.getInstrumentation().toMap();
+      /*
+       Test of statistic values after creating a directory and a file ;
+       getFileStatus is called 1 time after creating file and 1 time at
+       time of initialising.
+       */
+      assertEquals("Mismatch in op_create", 1,
+          (long) metricMap.get("op_create"));
+      assertEquals("Mismatch in op_create_non_recursive", 1,
+          (long) metricMap.get("op_create_non_recursive"));
+      assertEquals("Mismatch in files_created", 1,
+          (long) metricMap.get("files_created"));
+      assertEquals("Mismatch in directories_created", 1,
+          (long) metricMap.get("directories_created"));
+      assertEquals("Mismatch in op_mkdirs", 1,
+          (long) metricMap.get("op_mkdirs"));
+      assertEquals("Mismatch in op_get_file_status", 2,
+          (long) metricMap.get("op_get_file_status"));
+
+    } finally {
+      fs.close();

Review comment:
       Realized after committing that teardown is already doing this.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to