Skip to content

KAFKA-18613: Unit tests for usage of incorrect RPCs #18383

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

Merged
merged 4 commits into from
Apr 1, 2025

Conversation

lucasbru
Copy link
Member

@lucasbru lucasbru commented Jan 3, 2025

In the GroupMetadataManager, we may call an RPC on an incorrect group type. This adds unit tests to validate the behavior when an RPC is used on an incorrect group type.

Reviewers: Bill Bejeck [email protected]

@lucasbru lucasbru requested a review from bbejeck January 3, 2025 16:41
@@ -741,6 +741,7 @@ public List<StreamsGroupDescribeResponseData.DescribedGroup> streamsGroupDescrib
describedGroups.add(new StreamsGroupDescribeResponseData.DescribedGroup()
.setGroupId(groupId)
.setErrorCode(Errors.GROUP_ID_NOT_FOUND.code())
.setErrorMessage(exception.getMessage())
Copy link
Member Author

Choose a reason for hiding this comment

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

This was actually inconsistent to other group types

@@ -18,6 +18,7 @@
package org.apache.kafka.coordinator.group.taskassignor;

import org.apache.kafka.coordinator.group.GroupCoordinatorConfig;

Copy link
Member Author

Choose a reason for hiding this comment

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

spotlessApply

@@ -9373,7 +9375,8 @@ public void testStreamsGroupDescribeBeforeAndAfterCommittingOffset() {
List<StreamsGroupDescribeResponseData.DescribedGroup> actual = context.groupMetadataManager.streamsGroupDescribe(Collections.singletonList(streamsGroupId), context.lastCommittedOffset);
StreamsGroupDescribeResponseData.DescribedGroup describedGroup = new StreamsGroupDescribeResponseData.DescribedGroup()
.setGroupId(streamsGroupId)
.setErrorCode(Errors.GROUP_ID_NOT_FOUND.code());
.setErrorCode(Errors.GROUP_ID_NOT_FOUND.code())
.setErrorMessage("Group " + streamsGroupId + " not found.");
Copy link
Member Author

Choose a reason for hiding this comment

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

Updates behavior according to the above change to production code.

@@ -15673,6 +15676,349 @@ public void testReplayStreamsGroupTopologyTombstone() {
assertThrows(GroupIdNotFoundException.class, () -> context.groupMetadataManager.streamsGroup("bar"));
}

@Test
public void testConsumerGroupHeartbeatOnStreamsGroup() {
Copy link
Member Author

Choose a reason for hiding this comment

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

The test are pretty repetitive - like the ones for the other group types. I considered saving some LOC (by using private helper methods, and parametrized tests), but kept them at way, since it's going to be easier to refactor if each test is self-contained.

@lucasbru
Copy link
Member Author

lucasbru commented Feb 4, 2025

@bbejeck is this still on your list?

Copy link
Member

@bbejeck bbejeck 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 @lucasbru - overall LGTM. There does not seem to be too much variance in creating a majority of the GroupMetadataManagerTestContext object, maybe one helper method could help in this case. But that's up to you.

@lucasbru lucasbru force-pushed the kip1071pr/gmm_tests branch from caa4e6c to 3df4603 Compare March 12, 2025 14:26
@github-actions github-actions bot added streams core Kafka Broker producer consumer tools connect performance kraft mirror-maker-2 dependencies Pull requests that update a dependency file storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature KIP-932 Queues for Kafka build Gradle build or GitHub Actions docker Official Docker image generator RPC and Record code generator transactions Transactions and EOS clients labels Mar 12, 2025
@lucasbru lucasbru changed the base branch from kip1071 to trunk March 12, 2025 14:28
@lucasbru lucasbru changed the title Unit tests for usage of incorrect RPCs / group type pairs KAFKA-18613: Unit tests for usage of incorrect RPCs Mar 12, 2025
@lucasbru
Copy link
Member Author

I retargeted this to trunk (I thought I had already). The tests weren't changed.

@lucasbru lucasbru added KIP-1071 PRs related to KIP-1071 and removed connect performance kraft mirror-maker-2 dependencies Pull requests that update a dependency file storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature KIP-932 Queues for Kafka build Gradle build or GitHub Actions docker Official Docker image generator RPC and Record code generator transactions Transactions and EOS clients labels Mar 12, 2025
@lucasbru lucasbru force-pushed the kip1071pr/gmm_tests branch 2 times, most recently from 999d3be to 869234a Compare March 17, 2025 10:32
@lucasbru lucasbru force-pushed the kip1071pr/gmm_tests branch from 869234a to cbe6f3d Compare March 31, 2025 09:20
Tests for joining with missing source topics,
internal topics, incorrectly partitioned topics,
and stale topologies.
In the GroupMetadataManager, we may call an RPC on an incorrect group
type. This adds unit tests to validate the behavior when an RPC is
used on an incorrect group type.
@lucasbru lucasbru force-pushed the kip1071pr/gmm_tests branch from cbe6f3d to 3d71777 Compare March 31, 2025 11:25
@github-actions github-actions bot added the tests Test fixes (including flaky tests) label Mar 31, 2025
@lucasbru lucasbru merged commit e380968 into apache:trunk Apr 1, 2025
22 checks passed
janchilling pushed a commit to janchilling/kafka that referenced this pull request Apr 4, 2025
In the GroupMetadataManager, we may call an RPC on an incorrect group
type. This adds unit tests to validate the behavior when an RPC is used
on an incorrect group type.

Reviewers: Bill Bejeck <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIP-1071 PRs related to KIP-1071 streams tests Test fixes (including flaky tests)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants