jeffkbkim commented on code in PR #14467:
URL: https://github.com/apache/kafka/pull/14467#discussion_r1349340087


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/OffsetMetadataManagerTest.java:
##########
@@ -1763,6 +1803,120 @@ public void testDeleteGroupAllOffsets(Group.GroupType 
groupType) {
         assertEquals(3, numDeleteOffsets);
     }
 
+    @Test
+    public void testIsExpiredOffset() {
+        long currentTimestamp = 1000L;
+        long baseTimestamp = 500L;
+        OptionalLong expireTimestampMs = OptionalLong.of(1500);
+        long offsetsRetentionMs = 500L;
+
+        // Current timestamp >= expire timestamp => should expire
+        assertFalse(OffsetMetadataManager.isExpiredOffset(currentTimestamp, 
baseTimestamp, expireTimestampMs, offsetsRetentionMs));
+
+        // Current timestamp < expire timestamp => should not expire
+        currentTimestamp = 499;
+        assertFalse(OffsetMetadataManager.isExpiredOffset(currentTimestamp, 
baseTimestamp, expireTimestampMs, offsetsRetentionMs));
+
+        // Expire timestamp does not exist (current version with no per 
partition retention)
+        // Current timestamp - base timestamp >= offsets retention => should 
expire
+        expireTimestampMs = OptionalLong.empty();
+        currentTimestamp = 1000L;
+        assertTrue(OffsetMetadataManager.isExpiredOffset(currentTimestamp, 
baseTimestamp, expireTimestampMs, offsetsRetentionMs));
+
+        // Current timestamp - base timestamp < offsets retention => should 
not expire
+        currentTimestamp = 999L;
+        assertFalse(OffsetMetadataManager.isExpiredOffset(currentTimestamp, 
baseTimestamp, expireTimestampMs, offsetsRetentionMs));
+    }
+
+    @Test
+    public void testCleanupExpiredOffsetsGroupDoesNotExist() {
+        OffsetMetadataManagerTestContext context = new 
OffsetMetadataManagerTestContext.Builder()
+            .build();
+
+        List<Record> records = new ArrayList<>();
+        assertTrue(context.cleanupExpiredOffsets("unknown-group-id", records));

Review Comment:
   i think returning `true` makes more sense here because the return value 
specifies whether the group does not have any offsets remaining. If the group 
does not exist in the offsets map, we know the group can be deleted.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to