Skip to content

Conversation

@TaiJuWu
Copy link
Collaborator

@TaiJuWu TaiJuWu commented Oct 4, 2025

This PR migrates several unit tests from UnifiedLogTest.scala to
UnifiedLogTest.java as part of the ongoing effort to convert core broker
logic and tests to Java.

The following test methods have been rewritten and moved:

  • testDeleteOldSegments
  • testLogDeletionAfterClose
  • testLogDeletionAfterDeleteRecords
  • shouldDeleteSizeBasedSegments
  • shouldNotDeleteSizeBasedSegmentsWhenUnderRetentionSize
  • shouldDeleteTimeBasedSegmentsReadyToBeDeleted
  • shouldNotDeleteTimeBasedSegmentsWhenNoneReadyToBeDeleted
  • shouldNotDeleteSegmentsWhenPolicyDoesNotIncludeDelete

shouldDeleteSegmentsReadyToBeDeletedWhenCleanupPolicyIsCompactAndDelete

  • shouldDeleteLocalLogSegmentsWhenPolicyIsEmptyWithSizeRetention
  • shouldDeleteLocalLogSegmentsWhenPolicyIsEmptyWithMsRetention
  • shouldDeleteStartOffsetBreachedSegmentsWhenPolicyDoesNotIncludeDelete
  • shouldApplyEpochToMessageOnAppendIfLeader

followerShouldSaveEpochInformationFromReplicatedMessagesToTheEpochCache

  • shouldTruncateLeaderEpochsWhenDeletingSegments
  • shouldUpdateOffsetForLeaderEpochsWhenDeletingSegments
  • shouldTruncateLeaderEpochCheckpointFileWhenTruncatingLogt
  • testFirstUnstableOffsetNoTransactionalData
  • testFirstUnstableOffsetWithTransactionalData

New Utility Methods: To support the Java tests, new utility methods,
including LogConfigBuilder and transactional append helpers, were added
to LogTestUtils.java.

Reviewers: Chia-Ping Tsai [email protected]

@github-actions github-actions bot added triage PRs from the community core Kafka Broker tests Test fixes (including flaky tests) storage Pull requests that target the storage module clients labels Oct 4, 2025
@github-actions github-actions bot removed the triage PRs from the community label Oct 4, 2025
* Helper functions for writing unit tests.
* <p>
* <b>Package-private:</b> Not intended for use outside {@code org.apache.kafka.common.test}.
* Use {@code org/apache/kafka/test/TestUtils} instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need this comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to this package is not public, the intention is letting other person know where can find the TestUtil could be used.
If there is no comment, we need to extra time to find it

build();
}

public static MemoryRecords singletonRecords(byte[] value, byte[] key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move those helpers to UnifiedLogTest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

there are some unused methods, but I assume they will be used in the follow-up

}

log.updateHighWatermark(log.logEndOffset());
log.deleteOldSegments();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add assert to ensure it does delete some segments?

@chia7712
Copy link
Member

@TaiJuWu could you fix the conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clients core Kafka Broker storage Pull requests that target the storage module tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants