jojochuang commented on code in PR #8392:
URL: https://github.com/apache/ozone/pull/8392#discussion_r2078127642


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java:
##########
@@ -299,4 +300,59 @@ public static void validatePreviousSnapshotId(SnapshotInfo 
snapshotInfo,
           OMException.ResultCodes.INVALID_REQUEST);
     }
   }
+
+  /**
+   * Compares the block location info of 2 key info.
+   * @return true if block locations are same else false.
+   */
+  public static boolean isBlockLocationInfoSame(OmKeyInfo prevKeyInfo,

Review Comment:
   this is a relatively complex helper method. A test for this helper for 
various corner cases would be ideal.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/filter/TestReclaimableKeyFilter.java:
##########
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.snapshot.filter;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.ozone.om.KeyManager;
+import org.apache.hadoop.ozone.om.OmSnapshot;
+import org.apache.hadoop.ozone.om.OmSnapshotManager;
+import org.apache.hadoop.ozone.om.OzoneManager;
+import org.apache.hadoop.ozone.om.SnapshotChainManager;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
+import org.apache.hadoop.ozone.om.lock.IOzoneManagerLock;
+import org.apache.hadoop.ozone.om.snapshot.ReferenceCounted;
+import org.apache.hadoop.ozone.om.snapshot.SnapshotUtils;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.rocksdb.RocksDBException;
+
+/**
+ * Test class for ReclaimableKeyFilter.
+ */

Review Comment:
   ```suggestion
   /**
    * Test class for verifying the behavior of ReclaimableKeyFilter.
    *
    * <p>The ReclaimableKeyFilter determines whether deleted key entries
    * can be reclaimed based on their presence in earlier snapshots of the 
snapshot chain.
    * Specifically, if a deleted key is absent in the previous snapshot, it is 
deemed reclaimable.
    * If the key is referenced in prior snapshots, it should not be reclaimed.
    *
    * <p>This test class exercises a variety of scenarios to ensure that:
    * <ul>
    *   <li>Keys that disappear from the snapshot chain are correctly 
identified as reclaimable.</li>
    *   <li>Keys that are still referenced in one or more previous snapshots 
are not marked for reclamation.</li>
    *   <li>Exclusive size computations for snapshots are updated appropriately 
when reclaimable keys are identified.</li>
    * </ul>
    *
    * <p>Parameterization is used to simulate multiple conditions including:
    * <ul>
    *   <li>The number of previous snapshots available in the chain.</li>
    *   <li>Different snapshot indices to test edge cases when keys transition 
between reclaimable and non-reclaimable states.</li>
    * </ul>
    *
    * <p>Internally, the tests create mock metadata environments to simulate 
the state of snapshots,
    * enabling comprehensive verification of the filtering logic.
    *
    * @see org.apache.hadoop.ozone.om.snapshot.filter.ReclaimableKeyFilter
    */
   ```



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