GeorgeJahad commented on a change in pull request #2629:
URL: https://github.com/apache/ozone/pull/2629#discussion_r705857626



##########
File path: 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmMetrics.java
##########
@@ -276,33 +279,45 @@ public void testKeyOps() throws IOException {
     assertCounter("NumTrashKeyLists", 1L, omMetrics);
     assertCounter("NumKeys", 0L, omMetrics);
     assertCounter("NumInitiateMultipartUploads", 1L, omMetrics);
+    
 
-
-    ozoneManager.openKey(keyArgs);
-    ozoneManager.commitKey(keyArgs, 0);
-    ozoneManager.openKey(keyArgs);
-    ozoneManager.commitKey(keyArgs, 0);
-    ozoneManager.openKey(keyArgs);
-    ozoneManager.commitKey(keyArgs, 0);
-    ozoneManager.deleteKey(keyArgs);
+    keyArgs = createKeyArgs();
+    OpenKeySession keySession = writeClient.openKey(keyArgs);
+    writeClient.commitKey(keyArgs, keySession.getId());
+    keyArgs = createKeyArgs();
+    keySession = writeClient.openKey(keyArgs);
+    writeClient.commitKey(keyArgs, keySession.getId());
+    keyArgs = createKeyArgs();
+    keySession = writeClient.openKey(keyArgs);
+    writeClient.commitKey(keyArgs, keySession.getId());
+    writeClient.deleteKey(keyArgs);
 
 
     omMetrics = getMetrics("OMMetrics");
     assertCounter("NumKeys", 2L, omMetrics);
 
-    // inject exception to test for Failure Metrics
-    Mockito.doThrow(exception).when(mockKm).openKey(any());
-    Mockito.doThrow(exception).when(mockKm).deleteKey(any());
+    // inject exception to test for Failure Metrics on the read path
     Mockito.doThrow(exception).when(mockKm).lookupKey(any(), any());
     Mockito.doThrow(exception).when(mockKm).listKeys(
         any(), any(), any(), any(), anyInt());
     Mockito.doThrow(exception).when(mockKm).listTrash(
         any(), any(), any(), any(), anyInt());
-    Mockito.doThrow(exception).when(mockKm).commitKey(any(), anyLong());
-    Mockito.doThrow(exception).when(mockKm).initiateMultipartUpload(any());
-
     HddsWhiteboxTestUtils.setInternalState(
         ozoneManager, "keyManager", mockKm);
+
+    // inject exception to test for Failure Metrics on the write path
+    OMMetadataManager metadataManager = (OMMetadataManager)
+        HddsWhiteboxTestUtils.getInternalState(ozoneManager, 
"metadataManager");
+    OMMetadataManager mockMm = Mockito.spy(metadataManager);
+    Table<String, OmBucketInfo> bucketTable = (Table<String, OmBucketInfo>)
+        HddsWhiteboxTestUtils.getInternalState(metadataManager, "bucketTable");
+    Table<String, OmBucketInfo> mockBTable = Mockito.spy(bucketTable);
+    Mockito.doThrow(exception).when(mockBTable).isExist(any());
+    Mockito.doReturn(mockBTable).when(mockMm).getBucketTable();

Review comment:
       Spotbugs reported this about this line so I added an exemption:
   ```
   M D RV: Return value of OMMetadataManager.getBucketTable() ignored, but 
method has no side effect  At TestOmMetrics.java:[line 316]"
   ```
   




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

To unsubscribe, e-mail: [email protected]

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