guozhangwang commented on code in PR #12386: URL: https://github.com/apache/kafka/pull/12386#discussion_r923915840
########## streams/src/test/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdaterTest.java: ########## @@ -428,6 +456,55 @@ private void shouldRemoveStatefulTask(final Task task) throws Exception { verify(changelogReader).unregister(task.changelogPartitions()); } + @Test + public void shouldPauseActiveStatefulTask() throws Exception { + final StreamTask task = createActiveStatefulTaskInStateRestoring(TASK_0_0, Collections.singletonList(TOPIC_PARTITION_A_0)); + shouldPauseStatefulTask(task); + verify(changelogReader, never()).transitToUpdateStandby(); + } + + @Test + public void shouldPauseStandbyTask() throws Exception { + final StandbyTask task = createStandbyTaskInStateRunning(TASK_0_0, Collections.singletonList(TOPIC_PARTITION_A_0)); + shouldPauseStatefulTask(task); + verify(changelogReader, times(1)).transitToUpdateStandby(); + } + + @Test + public void shouldPauseActiveTaskAndTransitToUpdateStandby() throws Exception { + final StreamTask task1 = createActiveStatefulTaskInStateRestoring(TASK_0_0, Collections.singletonList(TOPIC_PARTITION_A_0)); + final StandbyTask task2 = createStandbyTaskInStateRunning(TASK_0_1, Collections.singletonList(TOPIC_PARTITION_B_0)); + + stateUpdater.start(); + stateUpdater.add(task1); + stateUpdater.add(task2); + + stateUpdater.pause(task1.id()); + + verifyPausedTasks(task1); + verifyCheckpointTasks(true, task1); + verifyRestoredActiveTasks(); + verifyRemovedTasks(); + verifyUpdatingTasks(task2); + verifyExceptionsAndFailedTasks(); + verify(changelogReader, times(1)).enforceRestoreActive(); + verify(changelogReader, times(1)).transitToUpdateStandby(); + } + + private void shouldPauseStatefulTask(final Task task) throws Exception { + stateUpdater.start(); + stateUpdater.add(task); + + stateUpdater.pause(task.id()); + + verifyPausedTasks(task); + verifyCheckpointTasks(true, task); + verifyRestoredActiveTasks(); + verifyRemovedTasks(); + verifyUpdatingTasks(); + verifyExceptionsAndFailedTasks(); + } + @Test public void shouldNotRemoveActiveStatefulTaskFromRestoredActiveTasks() throws Exception { Review Comment: Ack. -- 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