shashankhs11 commented on code in PR #20544:
URL: https://github.com/apache/kafka/pull/20544#discussion_r2361053799
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/TaskManagerTest.java:
##########
@@ -4248,28 +4215,32 @@ public boolean maybePunctuateStreamTime() {
@Test
public void shouldPunctuateActiveTasks() {
- final StateMachineTask task00 = new StateMachineTask(taskId00,
taskId00Partitions, true, stateManager) {
- @Override
- public boolean maybePunctuateStreamTime() {
- return true;
- }
- @Override
- public boolean maybePunctuateSystemTime() {
- return true;
- }
- };
+ final StreamTask task00 = statefulTask(taskId00,
taskId00ChangelogPartitions)
+ .withInputPartitions(taskId00Partitions)
+ .inState(State.RUNNING)
+ .build();
- when(consumer.assignment()).thenReturn(assignment);
- when(activeTaskCreator.createTasks(any(),
eq(taskId00Assignment))).thenReturn(singletonList(task00));
+ when(task00.maybePunctuateStreamTime()).thenReturn(true);
+ when(task00.maybePunctuateSystemTime()).thenReturn(true);
- taskManager.handleAssignment(taskId00Assignment, emptyMap());
- assertThat(taskManager.tryToCompleteRestoration(time.milliseconds(),
null), is(true));
+ final TasksRegistry tasks = mock(TasksRegistry.class);
+ when(tasks.activeTasks()).thenReturn(Set.of(task00));
- assertThat(task00.state(), is(Task.State.RUNNING));
+ when(stateUpdater.restoresActiveTasks()).thenReturn(false);
+ when(stateUpdater.hasExceptionsAndFailedTasks()).thenReturn(false);
+
when(stateUpdater.drainRestoredActiveTasks(any(Duration.class))).thenReturn(Set.of());
+
when(stateUpdater.drainExceptionsAndFailedTasks()).thenReturn(List.of());
+
+ final TaskManager taskManager =
setUpTaskManager(ProcessingMode.AT_LEAST_ONCE, tasks, false);
+
+ assertTrue(taskManager.checkStateUpdater(time.milliseconds(),
noOpResetter));
Review Comment:
You're right! I think it's not actually required for this specific test
case, but included it more as a safety check to ensure that the punctuation
should happen only when the system is "ready". But, we can safely omit the 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]