lucasbru commented on code in PR #14180: URL: https://github.com/apache/kafka/pull/14180#discussion_r1319560316
########## streams/src/test/java/org/apache/kafka/streams/processor/internals/tasks/DefaultTaskExecutorTest.java: ########## @@ -85,6 +85,16 @@ public void shouldShutdownTaskExecutor() { assertNull(taskExecutor.currentTask(), "Have task assigned after shutdown"); } + @Test + public void shouldAwaitProcessableTasksIfNoneAssignable() throws InterruptedException { + assertNull(taskExecutor.currentTask(), "Have task assigned before startup"); + when(task.isProcessable(anyLong())).thenReturn(false); + + taskExecutor.start(); + + verify(taskManager, timeout(VERIFICATION_TIMEOUT).atLeastOnce()).awaitProcessableTasks(); + } + Review Comment: Done ########## streams/src/test/java/org/apache/kafka/streams/processor/internals/tasks/DefaultTaskManagerTest.java: ########## @@ -73,6 +80,8 @@ public void setUp() { when(task.id()).thenReturn(new TaskId(0, 0, "A")); Review Comment: Done ########## streams/src/test/java/org/apache/kafka/streams/processor/internals/tasks/DefaultTaskManagerTest.java: ########## @@ -94,6 +103,114 @@ public void shouldAssignTaskThatCanBeProcessed() { assertNull(taskManager.assignNextTask(taskExecutor)); } + private class AwaitingRunnable implements Runnable { + private final CountDownLatch awaitDone = new CountDownLatch(1); + private final AtomicBoolean shutdownRequested = new AtomicBoolean(false); + @Override + public void run() { + while (!shutdownRequested.get()) { + try { + taskManager.awaitProcessableTasks(); + } catch (final InterruptedException ignored) { + } + awaitDone.countDown(); + } + } + + public void shutdown() { + shutdownRequested.set(true); + taskManager.signalProcessableTasks(); + } + } + + @Test + public void shouldBlockOnAwait() throws InterruptedException { Review Comment: I think it would be nice to keep it. But yeah, now I realize why I set this to 100. How about keeping it with 100? `shouldReturnFromAwaitOnInterruption` could pass if we always return immediately. -- 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