ChenSammi commented on code in PR #6033:
URL: https://github.com/apache/ozone/pull/6033#discussion_r1461362590


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestOpenKeyCleanupService.java:
##########
@@ -184,6 +189,46 @@ public void testCleanupExpiredOpenKeys(
     }
   }
 
+  /**
+   * In this test, we create a bunch of hsync keys with some keys having 
recover flag set.
+   * OpenKeyCleanupService should commit keys which don't have recovery flag 
and has expired.
+   * Keys with recovery flag and expired should be ignored by 
OpenKeyCleanupService.
+   * @throws IOException - on Failure.
+   */
+  @Test
+  @Timeout(300)
+  public void testIgnoreExpiredRecoverhsyncKeys() throws Exception {
+    OpenKeyCleanupService openKeyCleanupService =
+        (OpenKeyCleanupService) keyManager.getOpenKeyCleanupService();
+
+    openKeyCleanupService.suspend();
+    // wait for submitted tasks to complete
+    Thread.sleep(SERVICE_INTERVAL);
+    final long oldkeyCount = openKeyCleanupService.getSubmittedOpenKeyCount();
+    LOG.info("oldkeyCount={}", oldkeyCount);
+    assertEquals(0, oldkeyCount);
+
+    final OMMetrics metrics = om.getMetrics();
+    assertEquals(0, metrics.getNumOpenKeysHSyncCleaned());
+    int keyCount = 10;
+    createOpenKeys(keyCount, true, BucketLayout.FILE_SYSTEM_OPTIMIZED, false);
+    // create 2 more key and mark recovery flag set
+    createOpenKeys(2, true, BucketLayout.FILE_SYSTEM_OPTIMIZED, true);
+
+    // wait for open keys to expire
+    Thread.sleep(EXPIRE_THRESHOLD_MS);
+
+    // Only 10 keys should be returned after hard limit period, as 2 key is 
having recovery flag set
+    assertEquals(keyCount, getExpiredOpenKeys(true, 
BucketLayout.FILE_SYSTEM_OPTIMIZED));
+    assertExpiredOpenKeys(false, true,
+        BucketLayout.FILE_SYSTEM_OPTIMIZED);
+
+    openKeyCleanupService.resume();
+
+    // 10 keys should be recovered and there should not be any expired key 
pending
+    waitForOpenKeyCleanup(true, BucketLayout.FILE_SYSTEM_OPTIMIZED);
+  }

Review Comment:
   Could you add one more verification here, to make sure there are still two 
records in the openKeyTable? 



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