ArafatKhan2198 commented on code in PR #5693:
URL: https://github.com/apache/ozone/pull/5693#discussion_r1408754478


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerDoubleBuffer.java:
##########
@@ -340,35 +340,41 @@ public void testS3SecretCacheSizePostDoubleBufferFlush() 
throws IOException {
     Assertions.assertEquals("alice", ugiAlice.getShortUserName());
     when(ozoneManager.isS3Admin(ugiAlice)).thenReturn(true);
 
-    // Create 3 secrets and store them in the cache and double buffer.
-    processSuccessSecretRequest(userPrincipalId1, 1, true);
-    processSuccessSecretRequest(userPrincipalId2, 2, true);
-    processSuccessSecretRequest(userPrincipalId3, 3, true);
-
-    S3SecretCache cache = secretManager.cache();
-    // Check if all the three secrets are cached.
-    Assertions.assertTrue(cache.get(userPrincipalId1) != null);
-    Assertions.assertTrue(cache.get(userPrincipalId2) != null);
-    Assertions.assertTrue(cache.get(userPrincipalId3) != null);
-
-    // Flush the current buffer.
-    doubleBuffer.flushCurrentBuffer();
-
-    // Check if all the three secrets are cleared from the cache.
-    Assertions.assertTrue(cache.get(userPrincipalId3) == null);
-    Assertions.assertTrue(cache.get(userPrincipalId2) == null);
-    Assertions.assertTrue(cache.get(userPrincipalId1) == null);
-
-    // cleanup metrics
-    doubleBuffer.stopDaemon();
-    OzoneManagerDoubleBufferMetrics metrics =
-        doubleBuffer.getOzoneManagerDoubleBufferMetrics();
-    metrics.setMaxNumberOfTransactionsFlushedInOneIteration(0);
-    metrics.setAvgFlushTransactionsInOneIteration(0);
-    metrics.incrTotalSizeOfFlushedTransactions(
-        -metrics.getTotalNumOfFlushedTransactions());
-    metrics.incrTotalNumOfFlushOperations(
-        -metrics.getTotalNumOfFlushOperations());
+    try {
+      // Stop the double buffer thread to prevent automatic flushing every
+      // second and to enable manual flushing.
+      doubleBuffer.stopDaemon();
+
+      // Create 3 secrets and store them in the cache and double buffer.
+      processSuccessSecretRequest(userPrincipalId1, 1, true);
+      processSuccessSecretRequest(userPrincipalId2, 2, true);
+      processSuccessSecretRequest(userPrincipalId3, 3, true);
+
+      S3SecretCache cache = secretManager.cache();
+      // Check if all the three secrets are cached.
+      Assertions.assertTrue(cache.get(userPrincipalId1) != null);
+      Assertions.assertTrue(cache.get(userPrincipalId2) != null);
+      Assertions.assertTrue(cache.get(userPrincipalId3) != null);
+
+      // Flush the current buffer.
+      doubleBuffer.flushCurrentBuffer();
+
+      // Check if all the three secrets are cleared from the cache.
+      Assertions.assertTrue(cache.get(userPrincipalId3) == null);
+      Assertions.assertTrue(cache.get(userPrincipalId2) == null);
+      Assertions.assertTrue(cache.get(userPrincipalId1) == null);
+    } finally {
+      // cleanup metrics
+      doubleBuffer.stopDaemon();

Review Comment:
   Done!



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