squah-confluent commented on code in PR #24315:
URL: https://github.com/apache/kafka/pull/24315#discussion_r4708902312
##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java:
##########
@@ -14618,56 +14561,110 @@ fooTopicName, computeTopicHash(fooTopicName,
metadataImage)
assertEquals("Malformed embedded consumer protocol in subscription
deserialization.", ex.getMessage());
}
- @Test
- public void
testConsumerGroupHeartbeatToClassicGroupFromExistingStaticMember() {
+ /**
+ * Tests the upgrade of a classic group at different stages of a rebalance
by a static member that
+ * restarts with the consumer protocol. The classic group is advanced from
Stable at generation 1 to
+ * the given state, then the static member replaces itself with the same
subscription.
+ *
+ * @param state The state of the classic group when it is upgraded.
+ * @see #testConsumerGroupHeartbeatWithClassicGroup(ClassicGroupState)
+ */
+ @ParameterizedTest
+ @EnumSource(value = ClassicGroupState.class, names =
{"PREPARING_REBALANCE", "COMPLETING_REBALANCE", "STABLE"})
+ public void
testConsumerGroupHeartbeatWithClassicGroupFromExistingStaticMember(ClassicGroupState
state) throws Exception {
String groupId = "group-id";
- String memberId = "member-id";
- String instanceId = "instance-id";
+ String memberId1 = "member-id-1";
+ String memberId2 = "member-id-2";
+ String instanceId1 = "instance-id-1";
+ String newMemberId1 = Uuid.randomUuid().toString();
Uuid fooTopicId = Uuid.randomUuid();
String fooTopicName = "foo";
+ Uuid barTopicId = Uuid.randomUuid();
+ String barTopicName = "bar";
+
+ MockPartitionAssignor assignor = new MockPartitionAssignor("range");
+ assignor.prepareGroupAssignment(new GroupAssignment(Map.of(
+ newMemberId1, new MemberAssignmentImpl(mkAssignment(
+ mkTopicAssignment(fooTopicId, 0, 1)
+ )),
+ memberId2, new MemberAssignmentImpl(mkAssignment(
+ mkTopicAssignment(barTopicId, 0)
+ ))
+ )));
CoordinatorMetadataImage metadataImage = new MetadataImageBuilder()
- .addTopic(fooTopicId, fooTopicName, 1)
+ .addTopic(fooTopicId, fooTopicName, 2)
+ .addTopic(barTopicId, barTopicName, 1)
.addRacks()
.buildCoordinatorMetadataImage();
GroupMetadataManagerTestContext context = new
GroupMetadataManagerTestContext.Builder()
.withConfig(GroupCoordinatorConfig.CONSUMER_GROUP_MIGRATION_POLICY_CONFIG,
ConsumerGroupMigrationPolicy.UPGRADE.toString())
-
.withConfig(GroupCoordinatorConfig.CONSUMER_GROUP_ASSIGNORS_CONFIG, List.of(new
NoOpPartitionAssignor()))
+
.withConfig(GroupCoordinatorConfig.CONSUMER_GROUP_ASSIGNOR_OFFLOAD_ENABLE_CONFIG,
false)
Review Comment:
The existing test matrix is full coverage of `{STABLE, PREPARING_REBALANCE,
COMPLETING_REBALANCE} x {generation N, generation 0*} x {new member, static
member replacement, new member with non-matching regex}`.
I prefer to choose `{STABLE, PREPARING_REBALANCE, COMPLETING_REBALANCE} x
{generation N, generation 0*} x {new member}` for the offload variants, so we
now have:
* `testConsumerGroupHeartbeatWithClassicGroupWithAssignorOffload` - ~happy
path upgrade with offload
*
`testConsumerGroupHeartbeatWithClassicGroupAtGenerationZeroWithAssignorOffload`
- generation 0 upgrade with offload which is enough to demonstrate the
`KAFKA-21584` bug.
\*`PREPARING_REBALANCE` only.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]