ableegoldman commented on a change in pull request #8775:
URL: https://github.com/apache/kafka/pull/8775#discussion_r435374125



##########
File path: 
streams/src/test/java/org/apache/kafka/streams/processor/internals/assignment/ClientStateTest.java
##########
@@ -300,20 +302,71 @@ public void 
shouldNotHaveUnfulfilledQuotaWhenActiveTaskSizeGreaterEqualThanCapac
     @Test
     public void shouldAddTasksWithLatestOffsetToPrevActiveTasks() {
         final Map<TaskId, Long> taskOffsetSums = 
Collections.singletonMap(TASK_0_1, Task.LATEST_OFFSET);
-        client.addPreviousTasksAndOffsetSums(taskOffsetSums);
+        client.addPreviousTasksAndOffsetSums("c1", taskOffsetSums);
         client.initializePrevTasks(Collections.emptyMap());
         assertThat(client.prevActiveTasks(), 
equalTo(Collections.singleton(TASK_0_1)));
         assertThat(client.previousAssignedTasks(), 
equalTo(Collections.singleton(TASK_0_1)));
         assertTrue(client.prevStandbyTasks().isEmpty());
     }
 
+    @Test
+    public void shouldReturnPreviousStatefulTasksForConsumer() {
+        client.addPreviousTasksAndOffsetSums("c1", 
Collections.singletonMap(TASK_0_1, Task.LATEST_OFFSET));
+        client.addPreviousTasksAndOffsetSums("c2", 
Collections.singletonMap(TASK_0_2, 0L));
+        client.addPreviousTasksAndOffsetSums("c3", Collections.emptyMap());
+
+        client.initializePrevTasks(Collections.emptyMap());
+        client.computeTaskLags(
+            UUID_1,
+            mkMap(
+                mkEntry(TASK_0_1, 1_000L),
+                mkEntry(TASK_0_2, 1_000L)
+            )
+        );
+
+        assertThat(client.previousTasksForConsumer("c1"), 
equalTo(mkSortedSet(TASK_0_1)));
+        assertThat(client.previousTasksForConsumer("c2"), 
equalTo(mkSortedSet(TASK_0_2)));
+        assertTrue(client.previousTasksForConsumer("c3").isEmpty());
+    }
+
+    @Test
+    public void 
shouldReturnPreviousStatefulTasksForConsumerWhenLagIsNotComputed() {
+        client.addPreviousTasksAndOffsetSums("c1", 
Collections.singletonMap(TASK_0_1, 1000L));
+        client.initializePrevTasks(Collections.emptyMap());
+
+        assertThat(client.previousTasksForConsumer("c1"), 
equalTo(mkSortedSet(TASK_0_1)));
+    }
+
+    @Test
+    public void 
shouldReturnPreviousStatefulTasksForConsumerInIncreasingLagOrder() {

Review comment:
       You didn't miss it, I just snuck it in there after your review :P
   
   Sorry, should have called out that I made some more changes. I think that 
was the only significant logical change though. I'll try pulling the sort out 
into the assignment code




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to