Copilot commented on code in PR #12197:
URL: https://github.com/apache/ozone/pull/12197#discussion_r4750195773


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyLifecycleService.java:
##########
@@ -3136,6 +3143,56 @@ void testMoveToTrashAbortTaskWhenTrashRootPrepareFails() 
throws Exception {
       }
     }
 
+    @ParameterizedTest
+    @ValueSource(strings = {"FILE_SYSTEM_OPTIMIZED", "OBJECT_STORE"})
+    void testKeyNotExpiredUntilDaysElapsed(BucketLayout bucketLayout)
+        throws IOException, TimeoutException, InterruptedException {
+      assumeTrue(useDays);
+      final String volumeName = getTestName();
+      final String bucketName = uniqueObjectName("bucket");
+      String keyPrefix = "key";
+      String rulePrefix = bucketLayout == FILE_SYSTEM_OPTIMIZED ? "" : 
keyPrefix;
+      long initialDeletedKeyCount = getDeletedKeyCount();
+      long initialKeyCount = getKeyCount(bucketLayout);
+
+      List<OmKeyArgs> keyList =
+          createKeys(volumeName, bucketName, bucketLayout, KEY_COUNT, 1, 
keyPrefix, null);
+      assertEquals(KEY_COUNT, keyList.size());
+      GenericTestUtils.waitFor(() -> getKeyCount(bucketLayout) - 
initialKeyCount == KEY_COUNT,
+          WAIT_CHECK_INTERVAL, 1000);
+
+      // Create a rule with days = 1 without advancing the clock

Review Comment:
   The clock is frozen before these keys are committed, so the first scan 
evaluates keys whose modification times are ahead of the clock. Even a 
regression that ignores the days interval (`daysInMilli = 0`) would therefore 
pass both the retention check and the check after advancing two days. Set the 
clock to a positive key age below one day, such as 12 hours, before installing 
the rule so the test detects premature expiration.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyLifecycleService.java:
##########
@@ -204,18 +206,22 @@ class TestKeyLifecycleService extends OzoneTestBase {
   private long bucketObjectID;
   private final List<FaultInjectorImpl> installedInjectors = new ArrayList<>();
   private final Set<String> createdLifecyclePolicies = new HashSet<>();
+  private MockClock testClock;
 
   @Parameter(0)
   private long stateSaveInternal;
 
   @Parameter(1)
   private long maxKeysProcessedPerState;
 
+  @Parameter(2)
+  private boolean useDays;
+
   static Stream<Arguments> stateSaveConfiguration() {
     return Stream.of(
-        Arguments.of(1, 1),
+        Arguments.of(1, 1, false),
         Arguments.of(KeyLifecycleServiceConfig.Defaults.STATE_SAVE_INTERVAL_MS,
-            KeyLifecycleServiceConfig.Defaults.STATE_SAVE_KEYS_PROCESSED)
+            KeyLifecycleServiceConfig.Defaults.STATE_SAVE_KEYS_PROCESSED, true)

Review Comment:
   Tying `useDays` to the state-save configuration removes existing 
date-expiration coverage: `testKeyUpdatedShouldNotGetDeleted` and 
`testKeyDeletedOrRenamed` both require `maxKeysProcessedPerState != 1`, so they 
now run only with days expiration. Days expiration is also never exercised with 
per-key state saving. Please retain both state-save configurations for each 
expiration mode so the additional coverage does not replace existing cases.



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