dajac commented on code in PR #14467: URL: https://github.com/apache/kafka/pull/14467#discussion_r1349653385
########## 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 agree in this case. However, if the group does not exist, https://github.com/apache/kafka/pull/14467/files#diff-a4ad0e0a77c78dde2a841d055dd64e15f7da00b8a2a9e3279d74b718d5c612bbR568 should throw an exception. Should we add a test for this case and rename `testCleanupExpiredOffsetsGroupDoesNotExist` to something like `testCleanupExpiredOffsetsGroupHasNoOffsets`? -- 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