Skip to content

MINOR: Split up ShareConsumerTest#22017

Open
AndrewJSchofield wants to merge 6 commits intoapache:trunkfrom
AndrewJSchofield:share-consumer-test-split
Open

MINOR: Split up ShareConsumerTest#22017
AndrewJSchofield wants to merge 6 commits intoapache:trunkfrom
AndrewJSchofield:share-consumer-test-split

Conversation

@AndrewJSchofield
Copy link
Copy Markdown
Member

@AndrewJSchofield AndrewJSchofield commented Apr 9, 2026

Split up the excessively large ShareConsumerTest into a handful of
smaller source files.

Reviewers: Chia-Ping Tsai chia7712@gmail.com

@github-actions github-actions bot added tests Test fixes (including flaky tests) clients labels Apr 9, 2026
@AndrewJSchofield AndrewJSchofield added the KIP-932 Queues for Kafka label Apr 10, 2026
import static org.junit.jupiter.api.Assertions.assertTrue;

@Timeout(1200)
@Tag("integration")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to add @Tag("integration") here? as I can see in @ClusterTest already covers this and is applied consistently across other test suites.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This one was an outlier and I'm not really sure why. I've added it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, it is redundant

Copy link
Copy Markdown
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.

@AndrewJSchofield thanks for this excellent refactor

@@ -131,7 +97,6 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

@SuppressWarnings({"ClassFanOutComplexity", "ClassDataAbstractionCoupling"})
@Timeout(1200)
@Tag("integration")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ClusterTest covers this tag out of box, so we are good to skip it here

import static org.junit.jupiter.api.Assertions.assertTrue;

@Timeout(1200)
@Tag("integration")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, it is redundant

import static org.junit.jupiter.api.Assertions.assertTrue;

@Timeout(1200)
@Tag("integration")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

import static org.junit.jupiter.api.Assertions.fail;

@Timeout(1200)
@Tag("integration")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

}
)
public static class WithAssignmentBatchingDisabledTest extends ShareConsumerRackAwareTest {
@Tag("integration")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

import static org.junit.jupiter.api.Assertions.assertTrue;

@Timeout(1200)
@Tag("integration")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;

public class ShareConsumerTestBase {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should it be abstract?

assertEquals(1, records.count());

// Waiting until the acquisition lock expires.
Thread.sleep(20000);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use a smaller group.share.record.lock.duration.ms here to make the test run faster?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's taken effort to get these tests to run reliably so I'm nervous about messing with the timeouts. It's a bit unpredictable ensuring that the timeout only happens when we want it to. Luckily there are few tests that wait like this.

Copy link
Copy Markdown
Contributor

@see-quick see-quick left a comment

Choose a reason for hiding this comment

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

👍, btw , I think there may be additional places in the integration tests where we are doing this redundantly (i.e., tagging integration) . It might be worth opening an issue so someone can clean it up and we can avoid these niche definitions. WDYT?

@chia7712
Copy link
Copy Markdown
Member

It might be worth opening an issue so someone can clean it up and we can avoid these niche definitions. WDYT?

That's a great idea! If you have some free cycles, please feel free to open a minor PR to address it. :)

@see-quick
Copy link
Copy Markdown
Contributor

It might be worth opening an issue so someone can clean it up and we can avoid these niche definitions. WDYT?

That's a great idea! If you have some free cycles, please feel free to open a minor PR to address it. :)

I will try this week if I found some spare time :)) Thanks.

Copy link
Copy Markdown
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.

@AndrewJSchofield thanks for this patch. a couple of comments left


@ClusterTestDefaults(
serverProperties = {
@ClusterConfigProperty(key = GroupCoordinatorConfig.SHARE_GROUP_ASSIGNMENT_INTERVAL_MS_CONFIG, value = "0")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like this test case was removed. Was this intentional, or an accidental deletion

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It had an empty body. I do not understand what it was testing so I presumed that it was a fragment of a piece of incomplete work. Removed on purpose. I may be mistaken about its value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since it extends ShareConsumerRackAwareTest, its purpose is to run testShareConsumerWithRackAwareAssignor without assignment batching.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It needs a comment 😄 I can reinstate it in the next commit, along with a comment.

producer.flush();

// The acknowledgement commit callback will try to call a method of ShareConsumer
shareConsumer.setAcknowledgementCommitCallback(new TestableAcknowledgementCommitCallbackWakeup<>(shareConsumer));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shareConsumer.setAcknowledgementCommitCallback((__, ___) -> shareConsumer.wakeup());

and we can remove TestableAcknowledgementCommitCallbackWakeup

producer.flush();

AtomicBoolean callbackCalled = new AtomicBoolean(false);
shareConsumer.setAcknowledgementCommitCallback(new TestableAcknowledgementCommitCallbackThrows(callbackCalled));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

            shareConsumer.setAcknowledgementCommitCallback((__, ___) -> {
                callbackCalled.set(true);
                throw new OutOfOrderSequenceException("Exception thrown in TestableAcknowledgementCommitCallbackThrows.onComplete");
            });

and we could remove TestableAcknowledgementCommitCallbackThrows

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

Labels

clients KIP-932 Queues for Kafka tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants