guozhangwang commented on code in PR #12279:
URL: https://github.com/apache/kafka/pull/12279#discussion_r902885750


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdaterTest.java:
##########
@@ -346,42 +369,48 @@ private void shouldRemoveStatefulTask(final Task task) 
throws Exception {
             .thenReturn(false);
         stateUpdater.add(task);
 
-        stateUpdater.remove(TASK_0_0);
+        stateUpdater.remove(task.id());
 
         verifyRemovedTasks(task);
+        verifyCheckpointTasks(true, task);
         verifyRestoredActiveTasks();
         verifyUpdatingTasks();
         verifyExceptionsAndFailedTasks();
-        
verify(changelogReader).unregister(Collections.singletonList(TOPIC_PARTITION_A_0));
+        verify(changelogReader).unregister(task.changelogPartitions());
     }
 
     @Test
     public void shouldNotRemoveActiveStatefulTaskFromRestoredActiveTasks() 
throws Exception {
         final StreamTask task = 
createActiveStatefulTaskInStateRestoring(TASK_0_0, 
Collections.singletonList(TOPIC_PARTITION_A_0));
-        shouldNotRemoveTaskFromRestoredActiveTasks(task);
+        shouldNotRemoveTaskFromRestoredActiveTasks(task, 
Collections.singleton(TOPIC_PARTITION_A_0));
     }
 
     @Test
     public void shouldNotRemoveStatelessTaskFromRestoredActiveTasks() throws 
Exception {
         final StreamTask task = createStatelessTaskInStateRestoring(TASK_0_0);
-        shouldNotRemoveTaskFromRestoredActiveTasks(task);
+        shouldNotRemoveTaskFromRestoredActiveTasks(task, 
Collections.emptySet());
     }
 
-    private void shouldNotRemoveTaskFromRestoredActiveTasks(final StreamTask 
task) throws Exception {
+    private void shouldNotRemoveTaskFromRestoredActiveTasks(final StreamTask 
task, final Set<TopicPartition> completedChangelogs) throws Exception {
         final StreamTask controlTask = 
createActiveStatefulTaskInStateRestoring(TASK_1_0, 
Collections.singletonList(TOPIC_PARTITION_B_0));
         when(changelogReader.completedChangelogs())
-            .thenReturn(Collections.singleton(TOPIC_PARTITION_A_0));
+            .thenReturn(completedChangelogs);
         when(changelogReader.allChangelogsCompleted())
             .thenReturn(false);
         stateUpdater.add(task);
         stateUpdater.add(controlTask);
         verifyRestoredActiveTasks(task);
 
+        // for stateless task, we should complete it without trying to commit
+        if (!completedChangelogs.isEmpty())
+            verifyCheckpointTasks(true, task);
+
         stateUpdater.remove(task.id());
         stateUpdater.remove(controlTask.id());
 
         verifyRemovedTasks(controlTask);
         verifyRestoredActiveTasks(task);
+        verifyCheckpointTasks(true, controlTask);

Review Comment:
   I agree we can remove the verification on checkpointing, but I feel we can 
still retain the additional param in the private function instead of assuming 
it's always `Collections.singleton(TOPIC_PARTITION_A_0)`. WDYT?



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