Skip to content

Conversation

m1a2st
Copy link
Collaborator

@m1a2st m1a2st commented Aug 29, 2025

There is any unit test for TimingWheel, we should add test for it.

Reviewers: Chia-Ping Tsai [email protected]

@m1a2st m1a2st changed the title MINOR: Add Unit test TimingWheel MINOR: Add Unit test TimingWheel Aug 29, 2025
@github-actions github-actions bot added triage PRs from the community core Kafka Broker labels Aug 29, 2025
@m1a2st m1a2st changed the title MINOR: Add Unit test TimingWheel MINOR: Add Unit test for TimingWheel Aug 29, 2025
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.

@m1a2st thanks for this patch. it looks great!

private final long tickMs = 10L;
private final int wheelSize = 5;

@BeforeEach
Copy link
Member

Choose a reason for hiding this comment

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

those variables could be initialized in constructor, right?

    private final long startMs = 1000L;
    private final long tickMs = 10L;
    private final int wheelSize = 5;
    private final DelayQueue<TimerTaskList> queue = new DelayQueue<>();
    private final AtomicInteger taskCounter = new AtomicInteger(0);
    private final TimingWheel timingWheel = new TimingWheel(tickMs, wheelSize, startMs, taskCounter, queue);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the separate test we will use these variables. If we initialize them in the constructor, we would need to add a test-only method for each variable, correct?

Copy link
Member

Choose a reason for hiding this comment

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

The default Junit 5 lifecycle is PER_METHOD, meaning each test case has its own test instance. That is why I suggest initializing those variables in the consutrcotr

@github-actions github-actions bot removed the triage PRs from the community label Sep 4, 2025
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

@chia7712
Copy link
Member

chia7712 commented Sep 4, 2025

shouldWorkWithRebalance pass on my local, and it is traced by https://issues.apache.org/jira/browse/KAFKA-14533

@chia7712 chia7712 merged commit 8076702 into apache:trunk Sep 4, 2025
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Kafka Broker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants