errose28 commented on a change in pull request #1351:
URL: https://github.com/apache/hadoop-ozone/pull/1351#discussion_r479513426



##########
File path: 
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmMetadataManager.java
##########
@@ -521,6 +527,80 @@ public void testListKeysWithFewDeleteEntriesInCache() 
throws Exception {
 
   }
 
+  @Test
+  public void testGetExpiredOpenKeys() throws Exception {
+    final String bucketName = "bucket";
+    final String volumeName = "volume";
+    final int numExpiredOpenKeys = 4;
+    final int numUnexpiredOpenKeys = 1;
+    final long clientID = 1000L;
+    // To create expired keys, they will be assigned a creation time twice as
+    // old as the minimum expiration time.
+    final long minExpiredTimeSeconds = ozoneConfiguration.getInt(
+            OZONE_OPEN_KEY_EXPIRE_THRESHOLD_SECONDS,
+            OZONE_OPEN_KEY_EXPIRE_THRESHOLD_SECONDS_DEFAULT);
+    final long expiredAgeMillis =
+            Instant.now().minus(minExpiredTimeSeconds * 2,
+                    ChronoUnit.SECONDS).toEpochMilli();
+
+    // Add expired keys to open key table.
+    // The method under test does not check for expired open keys in the
+    // cache, since they will be picked up once the cache is flushed.
+    Set<String> expiredKeys = new HashSet<>();
+    for (int i = 0; i < numExpiredOpenKeys; i++) {
+      OmKeyInfo keyInfo = TestOMRequestUtils.createOmKeyInfo(volumeName,
+              bucketName, "expired" + i, HddsProtos.ReplicationType.RATIS,
+              HddsProtos.ReplicationFactor.ONE, 0L, expiredAgeMillis);
+
+      TestOMRequestUtils.addKeyToTable(true, false,
+              keyInfo, clientID, 0L, omMetadataManager);
+
+      String groupID = omMetadataManager.getOpenKey(volumeName, bucketName,
+              keyInfo.getKeyName(), clientID);
+      expiredKeys.add(groupID);
+    }
+
+    // Add unexpired keys to open key table.
+    for (int i = 0; i < numUnexpiredOpenKeys; i++) {
+      OmKeyInfo keyInfo = TestOMRequestUtils.createOmKeyInfo(volumeName,
+              bucketName, "unexpired" + i, HddsProtos.ReplicationType.RATIS,
+              HddsProtos.ReplicationFactor.ONE);
+
+      TestOMRequestUtils.addKeyToTable(true, false,
+              keyInfo, clientID, 0L, omMetadataManager);
+
+      String groupID = omMetadataManager.getOpenKey(volumeName, bucketName,

Review comment:
       Yeah. Removed it and pushing again.




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