lianetm commented on code in PR #16673:
URL: https://github.com/apache/kafka/pull/16673#discussion_r1722229914
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessorTest.java:
##########
@@ -145,6 +148,39 @@ public void testResetPositionsProcess() {
verify(applicationEventProcessor).process(any(ResetPositionsEvent.class));
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testAssignmentChangeEvent(boolean withGroupId) {
+ final long currentTimeMs = 12345;
+ AssignmentChangeEvent event = new AssignmentChangeEvent(currentTimeMs,
12345, Collections.emptyList());
+
+ setupProcessor(withGroupId);
+ doReturn(true).when(subscriptionState).assignFromUser(any());
+ processor.process(event);
+ if (withGroupId) {
+ verify(commitRequestManager).updateAutoCommitTimer(currentTimeMs);
+ verify(commitRequestManager).maybeAutoCommitAsync();
+ } else {
+ verify(commitRequestManager,
never()).updateAutoCommitTimer(currentTimeMs);
+ verify(commitRequestManager, never()).maybeAutoCommitAsync();
+ }
+ verify(metadata).requestUpdateForNewTopics();
Review Comment:
let's `verify(subscriptionState).assignFromUser` to call to update the
subscription state actually happens. We could even validate the param because
we know it (if we provide a set of partitions to the event in ln 155, then the
assignFromUser call should receive the same set of partitions)
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessorTest.java:
##########
@@ -145,6 +148,39 @@ public void testResetPositionsProcess() {
verify(applicationEventProcessor).process(any(ResetPositionsEvent.class));
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testAssignmentChangeEvent(boolean withGroupId) {
+ final long currentTimeMs = 12345;
+ AssignmentChangeEvent event = new AssignmentChangeEvent(currentTimeMs,
12345, Collections.emptyList());
+
+ setupProcessor(withGroupId);
+ doReturn(true).when(subscriptionState).assignFromUser(any());
+ processor.process(event);
+ if (withGroupId) {
+ verify(commitRequestManager).updateAutoCommitTimer(currentTimeMs);
+ verify(commitRequestManager).maybeAutoCommitAsync();
+ } else {
+ verify(commitRequestManager,
never()).updateAutoCommitTimer(currentTimeMs);
+ verify(commitRequestManager, never()).maybeAutoCommitAsync();
+ }
+ verify(metadata).requestUpdateForNewTopics();
+ assertDoesNotThrow(() -> event.future().get());
+
Review Comment:
nit: remove extra line?
--
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]