Skip to content

Conversation

TaiJuWu
Copy link
Collaborator

@TaiJuWu TaiJuWu commented Jan 15, 2025

Jira: https://issues.apache.org/jira/browse/KAFKA-18529

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@github-actions github-actions bot added triage PRs from the community core Kafka Broker tests Test fixes (including flaky tests) labels Jan 15, 2025
@lianetm
Copy link
Member

lianetm commented Jan 15, 2025

Thanks for the patch @TaiJuWu ! Could you please merge trunk latest changes? Thanks!

@TaiJuWu
Copy link
Collaborator Author

TaiJuWu commented Jan 15, 2025

Thanks for the patch @TaiJuWu ! Could you please merge trunk latest changes? Thanks!

Done~~~~~~

assertEquals(1, getTestQuorumAndGroupProtocolParametersClassicGroupProtocolOnly.count())
val args = getTestQuorumAndGroupProtocolParametersClassicGroupProtocolOnly
assertEquals(2, getTestQuorumAndGroupProtocolParametersAll.count())
val args = getTestQuorumAndGroupProtocolParametersAll
.findFirst().get.get
Copy link
Member

Choose a reason for hiding this comment

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

if we're only keeping the first entry from the full protocol list we still won't be testing with both consumers right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for catching it, update!

@github-actions github-actions bot removed the triage PRs from the community label Jan 16, 2025
Copy link
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Hello @TaiJuWu, Thanks for this PR, left a comment

Arguments.of((args :+ true):_*),
Arguments.of((args :+ false):_*)
)
assertEquals(2, getTestQuorumAndGroupProtocolParametersAll.count())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we still need this assertion?

Copy link
Member

@lianetm lianetm Jan 16, 2025

Choose a reason for hiding this comment

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

makes sense to me to remove it, this test shouldn't care about the elements in the list, just make sure we use them all right? (this is the only comment left here imo @TaiJuWu, please take a look when you can and I'll take another look too). Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, remove it.

Copy link
Member

@lianetm lianetm left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@lianetm
Copy link
Member

lianetm commented Jan 17, 2025

Hey @TaiJuWu, could you please merge trunk latest changes? (some changes just went in on these files). Thanks!

@TaiJuWu
Copy link
Collaborator Author

TaiJuWu commented Jan 17, 2025

Hey @TaiJuWu, could you please merge trunk latest changes? (some changes just went in on these files). Thanks!

Done 😀

Copy link
Contributor

@kirktrue kirktrue left a comment

Choose a reason for hiding this comment

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

I'm curious about these changes. Do all of these tests actually create a Consumer? I don't see that immediately when looking at the test code 🤔

@kirktrue kirktrue added consumer KIP-848 The Next Generation of the Consumer Rebalance Protocol ctr Consumer Threading Refactor (KIP-848) clients labels Jan 17, 2025
@lianetm
Copy link
Member

lianetm commented Jan 17, 2025

They do by using the createConsumer and directly new KafkaConsumer (looking for those will show the usages).

That being said, good point that in the admin there seems to be some using only admin/producer, so we could review and clean up a bit if the consumer grp param if not needed. Thanks for pointing it out @kirktrue! Could you take a look @TaiJuWu ? Thanks!

Copy link
Contributor

@kirktrue kirktrue left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @TaiJuWu!

I'm not sure if I'm confused about the intent here. The majority of the integration tests that were updated to include the group protocol don't actually create any Consumer instances during the test. With this change, there are tens of tests that run twice unnecessarily. Is there a reason that I'm not seeing that these should all be changed?

Thanks!

Comment on lines 98 to 100
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testDescribeConfigWithOptionTimeoutMs(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 118 to 120
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testCreatePartitionWithOptionRetryOnQuotaViolation(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 144 to 146
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testDescribeUserScramCredentials(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 317 to 319
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testDescribeTransactions(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 403 to 405
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testDescribeTransactionsTimeout(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 3807 to 3809
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testIncrementalAlterConfigsForLog4jLogLevelsDoesNotWorkWithInvalidConfigs(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 3854 to 3855
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 3860 to 3861
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 3886 to 3888
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testListClientMetricsResources(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

Comment on lines 3922 to 3924
@ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
def testCreateTopicsReturnsConfigs(quorum: String, groupProtocol: String): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not create any Consumers, so this change should be reverted.

@kirktrue
Copy link
Contributor

To test whether or not a test needed to be updated, I changed the code that creates a Consumer:

diff --git a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerDelegateCreator.java b/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerDelegateCreator.java
index 74592972b9..fe70aebcee 100644
--- a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerDelegateCreator.java
+++ b/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerDelegateCreator.java
@@ -56,6 +56,9 @@ public class ConsumerDelegateCreator {
     public <K, V> ConsumerDelegate<K, V> create(ConsumerConfig config,
                                                 Deserializer<K> keyDeserializer,
                                                 Deserializer<V> valueDeserializer) {
+        if (true)
+            throw new RuntimeException("Intentionally blocking attempt to create a Consumer!");
+
         try {
             GroupProtocol groupProtocol = GroupProtocol.valueOf(config.getString(ConsumerConfig.GROUP_PROTOCOL_CONFIG).toUpperCase(Locale.ROOT));
 
@@ -79,6 +82,9 @@ public class ConsumerDelegateCreator {
                                                 SubscriptionState subscriptions,
                                                 ConsumerMetadata metadata,
                                                 List<ConsumerPartitionAssignor> assignors) {
+        if (true)
+            throw new RuntimeException("Intentionally blocking attempt to create a Consumer!");
+
         try {
             GroupProtocol groupProtocol = GroupProtocol.valueOf(config.getString(ConsumerConfig.GROUP_PROTOCOL_CONFIG).toUpperCase(Locale.ROOT));
 

Then I ran PlaintextAdminIntegrationTest locally.

Are there other changes in the queue that are going to start creating Consumers in these tests?

@chia7712
Copy link
Member

I agree with @kirktrue's suggestion that some tests do not utilize a consumer. Therefore, running these tests twice is redundant.

@TaiJuWu
Copy link
Collaborator Author

TaiJuWu commented Jan 18, 2025

Thanks @kirktrue for good point and suggestion , I will revisit all tests.

@github-actions github-actions bot added the small Small PRs label Jan 18, 2025
@TaiJuWu
Copy link
Collaborator Author

TaiJuWu commented Jan 18, 2025

Revert some change and do follow check:

1. Apply @kirktrue patch 
2. check all failure use two protocol but there are three exceptions
3. Successful case only run one time

three exception is

1. testDeleteRecordsAfterCorruptRecords, this like behavior difference but I have not checked totally.
2. testDescribeClassicGroups, this is for classic protocol
3. testListGroups, already include both protocol

Also apply https://github.com/apache/kafka/pull/18554/files#r1920843220

@TaiJuWu TaiJuWu force-pushed the KAFKA-18529-ConsumerRebootstrapTest branch from 226a078 to 560df51 Compare January 18, 2025 05:43
@Timeout(10)
def testDescribeUserScramCredentialsTimeout(quorum: String, groupProtocol: String): Unit = {
@ParameterizedTest
@ValueSource(strings = Array("kraft"))
Copy link
Member

@lianetm lianetm Jan 21, 2025

Choose a reason for hiding this comment

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

agree with this change, but interesting, this shows that PlainTestAdminIntegration was already running for async, even in cases where it was not needed, right?

So checking all these admin tests that were running for both consumers, I notice that testLogStartOffsetCheckpoint is somehow similar to this one, should we apply the same fix to it?

It's running for both but it really only uses a consumer to subscribeAndWaitForAssignment, which is already covered in many consumer-specific tests, is it valuable in this testLogStartOffsetCheckpoint? (seems unrelated). What do you think @kirktrue ? I see you enabled it for both consumers as part of #17670.

Also should we rename the jira/PR? It's only the ConsumerRebotstrap that was not running for async

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, at least one other committer has pushed back on enabling both consumer implementations anywhere that a consumer is created. I filed KAFKA-18087 to remedy that, but I haven't yet thought about the heuristic to apply to know when it's "safe" to just test the one consumer or the other.

Copy link
Contributor

Choose a reason for hiding this comment

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

To address your fourth question, yes, ideally we should update the Jira and PR to accurately reflect what's changing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rename jira and PR title.

Copy link
Member

Choose a reason for hiding this comment

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

but I haven't yet thought about the heuristic to apply to know when it's "safe" to just test the one consumer or the other.

we are on the same page :)

It's difficult to definitively confirm that "this functionality of the consumer is already covered by another test." Therefore, a simpler approach is to test both consumers if the test requires the use of a consumer.

Maybe we can revisit only the "slow" tests?

Copy link
Member

@lianetm lianetm Jan 23, 2025

Choose a reason for hiding this comment

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

agree, that could be a safe start.

Also, it could make sense to start by reviewing Admin and Producer tests that are running for both consumers. It's probably on those where we can have some good candidates to rollback.

@TaiJuWu TaiJuWu changed the title KAFKA-18529: PlaintextAdminIntegrationTest and ConsumerRebootstrapTest should run for async consumer KAFKA-18529: ConsumerRebootstrapTest should run for async consumer Jan 22, 2025
@lianetm
Copy link
Member

lianetm commented Jan 23, 2025

@TaiJuWu could you merge trunk latest changes to get rid of the test failures we have here? (ex. fixed in #18612). Thanks!

@TaiJuWu
Copy link
Collaborator Author

TaiJuWu commented Jan 24, 2025

@TaiJuWu could you merge trunk latest changes to get rid of the test failures we have here? (ex. fixed in #18612). Thanks!

Done :)

@lianetm lianetm merged commit 023f9c2 into apache:trunk Jan 24, 2025
9 checks passed
@TaiJuWu TaiJuWu deleted the KAFKA-18529-ConsumerRebootstrapTest branch January 25, 2025 04:33
pranavt84 pushed a commit to pranavt84/kafka that referenced this pull request Jan 27, 2025
airlock-confluentinc bot pushed a commit to confluentinc/kafka that referenced this pull request Jan 27, 2025
pdruley pushed a commit to pdruley/kafka that referenced this pull request Feb 12, 2025
manoj-mathivanan pushed a commit to manoj-mathivanan/kafka that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved clients consumer core Kafka Broker ctr Consumer Threading Refactor (KIP-848) KIP-848 The Next Generation of the Consumer Rebalance Protocol small Small PRs tests Test fixes (including flaky tests)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants