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

Unit tests for usage of incorrect RPCs / group type pairs #18383

Open
wants to merge 1 commit into
base: kip1071
Choose a base branch
from

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.

Committer Checklist (excluded from commit message)

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

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 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.

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.

1 participant