dajac commented on a change in pull request #11688:
URL: https://github.com/apache/kafka/pull/11688#discussion_r802450152



##########
File path: 
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinatorTest.java
##########
@@ -386,15 +386,39 @@ public void 
testPerformAssignmentShouldValidateCooperativeAssignment() {
             if (protocol == COOPERATIVE) {
                 // in cooperative protocol, we should throw exception when 
validating cooperative assignment
                 Exception e = assertThrows(IllegalStateException.class,
-                    () -> coordinator.performAssignment("1", 
partitionAssignor.name(), metadata));
+                    () -> coordinator.performAssignment("1", 
partitionAssignor.name(), metadata, false));
                 assertTrue(e.getMessage().contains("Assignor supporting the 
COOPERATIVE protocol violates its requirements"));
             } else {
                 // in eager protocol, we should not validate assignment
-                coordinator.performAssignment("1", partitionAssignor.name(), 
metadata);
+                coordinator.performAssignment("1", partitionAssignor.name(), 
metadata, false);
             }
         }
     }
 
+    @Test
+    public void testPerformAssignmentShouldSkipAssignment() {
+        SubscriptionState mockSubscriptionState = 
Mockito.mock(SubscriptionState.class);
+
+        Map<String, List<String>> memberSubscriptions = 
singletonMap(consumerId, singletonList(topic1));
+
+        List<JoinGroupResponseData.JoinGroupResponseMember> metadata = new 
ArrayList<>();
+        for (Map.Entry<String, List<String>> subscriptionEntry : 
memberSubscriptions.entrySet()) {
+            ConsumerPartitionAssignor.Subscription subscription = new 
ConsumerPartitionAssignor.Subscription(subscriptionEntry.getValue());
+            ByteBuffer buf = 
ConsumerProtocol.serializeSubscription(subscription);
+            metadata.add(new JoinGroupResponseData.JoinGroupResponseMember()
+                .setMemberId(subscriptionEntry.getKey())
+                .setMetadata(buf.array()));
+        }
+
+        // `partitionAssignor.prepare` is not called therefore calling 
`partitionAssignor.assign` will throw

Review comment:
       That method is part of `MockPartitionAssignor` which is extensively used 
in tests in this suite. I do agree with you than using a mock is more explicit 
here. Let me update that.




-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to