Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KIP-848 EA] Admin API for listing consumer groups now has #1267

Merged
merged 3 commits into from
Oct 10, 2024

Conversation

mahajanadhitya
Copy link
Contributor

@mahajanadhitya mahajanadhitya commented Aug 9, 2024

an optional filter to return only groups of given types

@mahajanadhitya mahajanadhitya requested review from a team as code owners August 9, 2024 08:51
Copy link
Contributor

@milindl milindl 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 changes! Looks mostly okay.

Remember to add it to CHANGELOG.md also

kafka/adminapi_test.go Show resolved Hide resolved

listres, err := a.ListConsumerGroups(
ctx, SetAdminRequestTimeout(time.Second),
SetAdminMatchConsumerGroupTypes([]ConsumerGroupType{classicGroupType, classicGroupType}))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SetAdminMatchConsumerGroupTypes([]ConsumerGroupType{classicGroupType, classicGroupType}))
SetAdminMatchConsumerGroupTypes([]ConsumerGroupType{classicGroupType, classicGroupType}))

Why is the same group type included twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is to test the INVALID_ARGS error code with duplicate group types.

Copy link
Contributor

@milindl milindl Aug 21, 2024

Choose a reason for hiding this comment

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

But your test is not checking for invalid args error code below, so change that. You're checking for deadline exceeded still.

kafka/build_darwin_amd64.go Outdated Show resolved Hide resolved
kafka/integration_test.go Outdated Show resolved Hide resolved
kafka/integration_test.go Outdated Show resolved Hide resolved
Comment on lines 850 to 854
// Generating a new topic/groupID to ensure a fresh group/topic is created.
rand.Seed(time.Now().Unix())
groupID := fmt.Sprintf("%s-%d", testconf.GroupID, rand.Int())
topic := fmt.Sprintf("%s-%d", testconf.TopicName, rand.Int())
nonExistentGroupID := fmt.Sprintf("%s-nonexistent-%d", testconf.GroupID, rand.Int())
Copy link
Contributor

Choose a reason for hiding this comment

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

Move above the "if" block, and remove from below too, so they're not duplicated

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for creation of adminclient, topic creation, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is done voluntarily because currently in semaphore we run the whole tests with broker version < 3.8.0.0 and then when we run with higher broker version on semaphore to test the consumer group protocol we only check the case of consumer group that is why we return at the end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, so since there is nothing common between the tests, why don't you split them? I don't see why we should have an entirely different test in an if block if there's any shared code between them, it just makes it harder to read.

TestAdminClient_ListAndDescribeConsumerGroupsClassic and TestAdminClient_ListConsumerGroupsConsumer

ctx, cancel := context.WithTimeout(context.Background(), expDuration)
defer cancel()

listres, err := a.ListConsumerGroups(
Copy link
Contributor

Choose a reason for hiding this comment

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

gofmt needs to be run

@@ -464,7 +467,10 @@ func testAdminAPIsListConsumerGroups(
t.Fatalf("Expected ConsumerGroupTypeFromString to work for Unknown type")
}

listres, err := a.ListConsumerGroups(
ctx, cancel := context.WithTimeout(context.Background(), expDuration)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this code doesn't run. Are the tests running when you are dynamically linking librdkafka? This is a compilation error because := and not =


listres, err := a.ListConsumerGroups(
ctx, SetAdminRequestTimeout(time.Second),
SetAdminMatchConsumerGroupTypes([]ConsumerGroupType{classicGroupType, classicGroupType}))
Copy link
Contributor

@milindl milindl Aug 21, 2024

Choose a reason for hiding this comment

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

But your test is not checking for invalid args error code below, so change that. You're checking for deadline exceeded still.

Comment on lines 850 to 854
// Generating a new topic/groupID to ensure a fresh group/topic is created.
rand.Seed(time.Now().Unix())
groupID := fmt.Sprintf("%s-%d", testconf.GroupID, rand.Int())
topic := fmt.Sprintf("%s-%d", testconf.TopicName, rand.Int())
nonExistentGroupID := fmt.Sprintf("%s-nonexistent-%d", testconf.GroupID, rand.Int())
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, so since there is nothing common between the tests, why don't you split them? I don't see why we should have an entirely different test in an if block if there's any shared code between them, it just makes it harder to read.

TestAdminClient_ListAndDescribeConsumerGroupsClassic and TestAdminClient_ListConsumerGroupsConsumer

Copy link
Contributor

@milindl milindl left a comment

Choose a reason for hiding this comment

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

Some more comments, please run the tests

@mahajanadhitya
Copy link
Contributor Author

confluent-kafka-go KIP 848 ListGroups API

Branch Name

feature/ListGroupsAPI

Build

Install the corresponding Librdkafka and build with go build -tags dynamic ./...

Unit Tests

confluent-kafka-go/kafka/adminapi_test.go via testAdminAPIsListConsumerGroups
go test -tags dynamic -timeout 30s -run ^TestAdminAPIs

Cluster

Spawn the trivup cluster in librdkafka/tests
./interactive_broker_version.py 'trunk@f6c9feea76d01a46319b0ca602d70aa855057b07' --port 9092 --kraft --conf '{"conf":["unstable.api.versions.enable=true","group.coordinator.new.enable=true","group.protocol=classic,consumer"]}'

Example

confluent-kafka-go/examples/admin_list_consumer_groups/admin_list_consumer_groups.go
go run -tags dynamic admin_list_consumer_groups.go localhost:9092 [-states <state1> <state2> ...] [-types <type1> <type2> ...]

Integration Tests

Remember to set the Environment Variable TEST_CONSUMER_GROUP_PROTOCOL to consumer/classic
confluent-kafka-go/kafka/integration_test.go via TestAdminClient_ListConsumerGroups
go test -v -tags dynamic -run ^TestIntegration -testify.m TestAdminClient_ListConsumerGroups

@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@emasab emasab changed the title ListGroups API KIP 848 [KIP-848 EA] Admin API for listing consumer groups now has Oct 9, 2024
@emasab emasab marked this pull request as draft October 9, 2024 18:43
@emasab
Copy link
Contributor

emasab commented Oct 9, 2024

Converting to draft until we merge v2.6.0-RC2

@emasab emasab marked this pull request as ready for review October 10, 2024 13:57
Copy link
Member

@pranavrth pranavrth left a comment

Choose a reason for hiding this comment

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

All doubts cleared over a call.
LGTM!.

@emasab emasab merged commit 654a47b into master Oct 10, 2024
3 checks passed
@emasab emasab deleted the feature/ListGroupsAPI branch October 10, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants