cadonna commented on code in PR #19889:
URL: https://github.com/apache/kafka/pull/19889#discussion_r2128074684


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/TaskManagerTest.java:
##########
@@ -4837,6 +4841,44 @@ public void 
shouldUseStartupTasksFromStateDirectoryAsStandbyWithStateUpdater() {
         assertEquals(Collections.singletonMap(taskId00, startupTask), 
taskManager.standbyTaskMap());
     }
 
+    @Test
+    public void shouldStartAndCleanlyShutdownStateUpdaterThread() {
+
+        final String stateUpdaterName = "test-state-updater";
+        final Metrics metrics = new Metrics(time);
+        final StreamsConfig config = new StreamsConfig(configProps());
+        final DefaultStateUpdater defaultStateUpdater =
+            new DefaultStateUpdater(stateUpdaterName, metrics, config, null, 
changeLogReader, topologyMetadata, time);
+
+        final TaskManager taskManager = new TaskManager(
+            time,
+            changeLogReader,
+            ProcessId.randomProcessId(),
+            "logPrefix",
+            activeTaskCreator,
+            standbyTaskCreator,
+            null,
+            topologyMetadata,
+            adminClient,
+            stateDirectory,
+            defaultStateUpdater,
+            null
+        );
+
+        taskManager.init();
+        assertTrue(defaultStateUpdater.isRunning());

Review Comment:
   You do not need to check for `isRunning()` here. `isRunning()` is an 
implementation detail of the `DefaultStateUpdater`. It suffices to verify that 
`stateUpdater.start()` is called on the mock. Something simple like the 
following:
   
   ```java
       @ParameterizedTest
       @ValueSource(booleans = {true, false})
       public void shouldStartStateUpdaterOnInit(final boolean 
stateUpdaterEnabled) {
           final TaskManager taskManager = 
setUpTaskManager(ProcessingMode.AT_LEAST_ONCE, stateUpdaterEnabled);
           taskManager.init();
           if (stateUpdaterEnabled) {
               verify(stateUpdater).start();
           } else {
               verify(stateUpdater, never()).start();
           }
       }
   ```
   The shutdown is tested elsewhere. You do not need to test it again here.



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