shwetayakkali commented on a change in pull request #1146: HDDS-1366. Add 
ability in Recon to track the number of small files in an Ozone Cluster
URL: https://github.com/apache/hadoop/pull/1146#discussion_r312281064
 
 

 ##########
 File path: 
hadoop-ozone/ozone-recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestUtilizationService.java
 ##########
 @@ -62,66 +64,73 @@ public void setUpResultList() {
             (long) i));
       }
     }
+    return resultList;
   }
 
   @Test
   public void testGetFileCounts() throws IOException {
-    setUpResultList();
+    List<FileCountBySize> resultList = setUpResultList();
 
     utilizationService = mock(UtilizationService.class);
     when(utilizationService.getFileCounts()).thenCallRealMethod();
     when(utilizationService.getDao()).thenReturn(fileCountBySizeDao);
     when(fileCountBySizeDao.findAll()).thenReturn(resultList);
 
-    utilizationService.getFileCounts();
+    Response response = utilizationService.getFileCounts();
+    // get result list from Response entity
+    List<FileCountBySize> responseList =
+        (List<FileCountBySize>) response.getEntity();
+
     verify(utilizationService, times(1)).getFileCounts();
     verify(fileCountBySizeDao, times(1)).findAll();
 
-    assertEquals(maxBinSize, resultList.size());
+    FileSizeCountTask fileSizeCountTask = mock(FileSizeCountTask.class);
+    when(fileSizeCountTask.getMaxFileSizeUpperBound()).
+        thenReturn(1125899906842624L);
+    when(fileSizeCountTask.getMaxBinSize()).thenReturn(maxBinSize);
+    when(fileSizeCountTask.calculateBinIndex(anyLong())).thenCallRealMethod();
+    assertEquals(maxBinSize, responseList.size());
+
     long fileSize = 4096L;              // 4KB
-    int index =  findIndex(fileSize);
-    long count = resultList.get(index).getCount();
+    int index =  fileSizeCountTask.calculateBinIndex(fileSize);
+
+    long count = responseList.get(index).getCount();
     assertEquals(index, count);
 
     fileSize = 1125899906842624L;       // 1PB
-    index = findIndex(fileSize);
-    count = resultList.get(index).getCount();
+    index = fileSizeCountTask.calculateBinIndex(fileSize);
+    count = responseList.get(index).getCount();
+    //last extra bin for files >= 1PB
     assertEquals(maxBinSize - 1, index);
     assertEquals(index, count);
 
     fileSize = 1025L;                   // 1 KB + 1B
-    index = findIndex(fileSize);
-    count = resultList.get(index).getCount(); //last extra bin for files >= 1PB
+    index = fileSizeCountTask.calculateBinIndex(fileSize);
+    count = responseList.get(index).getCount();
     assertEquals(index, count);
 
     fileSize = 25L;
-    index = findIndex(fileSize);
-    count = resultList.get(index).getCount();
+    index = fileSizeCountTask.calculateBinIndex(fileSize);
+    count = responseList.get(index).getCount();
     assertEquals(index, count);
 
     fileSize = 1125899906842623L;       // 1PB - 1B
-    index = findIndex(fileSize);
-    count = resultList.get(index).getCount();
+    index = fileSizeCountTask.calculateBinIndex(fileSize);
+    count = responseList.get(index).getCount();
     assertEquals(index, count);
 
     fileSize = 1125899906842624L * 4;       // 4 PB
-    index = findIndex(fileSize);
-    count = resultList.get(index).getCount();
+    index = fileSizeCountTask.calculateBinIndex(fileSize);
 
 Review comment:
   So, what exactly should testGetFileCounts() test? as part of assertions?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to