kirktrue commented on code in PR #15640:
URL: https://github.com/apache/kafka/pull/15640#discussion_r1603994499


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumerTest.java:
##########
@@ -1846,7 +1849,34 @@ public void 
testPollThrowsInterruptExceptionIfInterrupted() {
         }
         assertDoesNotThrow(() -> consumer.poll(Duration.ZERO));
     }
-    
+
+    @Test
+    void testReaperExpiresExpiredEvents() {
+        consumer = newConsumer();
+        final String topicName = "foo";
+        final int partition = 3;
+        final TopicPartition tp = new TopicPartition(topicName, partition);
+        final SortedSet<TopicPartition> partitions = new 
TreeSet<>(TOPIC_PARTITION_COMPARATOR);
+        partitions.add(tp);
+
+        consumer.subscribe(Collections.singletonList(topicName), new 
CounterConsumerRebalanceListener());
+
+        final ConsumerRebalanceListenerCallbackNeededEvent event1 = new 
ConsumerRebalanceListenerCallbackNeededEvent(ON_PARTITIONS_REVOKED, partitions);
+        final ConsumerRebalanceListenerCallbackNeededEvent event2 = new 
ConsumerRebalanceListenerCallbackNeededEvent(ON_PARTITIONS_ASSIGNED, 
partitions);
+        backgroundEventReaper.add(event1);
+        backgroundEventQueue.add(event2);
+
+        assertEquals(1, backgroundEventReaper.size());
+        assertEquals(1, backgroundEventQueue.size());
+
+        consumer.close();

Review Comment:
   Added tests for reaper invocation for `close()`, `poll()`, and 
`unsubscribe()`.



##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumerTest.java:
##########
@@ -1846,7 +1849,34 @@ public void 
testPollThrowsInterruptExceptionIfInterrupted() {
         }
         assertDoesNotThrow(() -> consumer.poll(Duration.ZERO));
     }
-    
+
+    @Test
+    void testReaperExpiresExpiredEvents() {
+        consumer = newConsumer();
+        final String topicName = "foo";
+        final int partition = 3;
+        final TopicPartition tp = new TopicPartition(topicName, partition);
+        final SortedSet<TopicPartition> partitions = new 
TreeSet<>(TOPIC_PARTITION_COMPARATOR);
+        partitions.add(tp);
+
+        consumer.subscribe(Collections.singletonList(topicName), new 
CounterConsumerRebalanceListener());
+
+        final ConsumerRebalanceListenerCallbackNeededEvent event1 = new 
ConsumerRebalanceListenerCallbackNeededEvent(ON_PARTITIONS_REVOKED, partitions);
+        final ConsumerRebalanceListenerCallbackNeededEvent event2 = new 
ConsumerRebalanceListenerCallbackNeededEvent(ON_PARTITIONS_ASSIGNED, 
partitions);
+        backgroundEventReaper.add(event1);
+        backgroundEventQueue.add(event2);
+
+        assertEquals(1, backgroundEventReaper.size());
+        assertEquals(1, backgroundEventQueue.size());
+
+        consumer.close();
+
+        assertEquals(0, backgroundEventReaper.size());
+        assertEquals(0, backgroundEventQueue.size());
+        assertTrue(event1.future().isCompletedExceptionally());
+        assertTrue(event2.future().isCompletedExceptionally());
+    }

Review Comment:
   Done.



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