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



##########
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:
       I missed the extra sort on my last review. It really seems like too much 
fanciness for the ClientState to sort the tasks in lag order. Would it be too 
messy to move the sort aspect out to the balancing code that needs it?




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