sunm2n commented on code in PR #24240:
URL: https://github.com/apache/kafka/pull/24240#discussion_r4594232328


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/GlobalStreamThreadTest.java:
##########
@@ -466,17 +539,56 @@ private HashMap<String, Object> getStreamProperties() {
     }
 
     private void initializeConsumer() {
-        mockConsumer.updatePartitions(
+        initializeConsumer(mockConsumer);
+    }
+
+    private void initializeConsumer(final MockConsumer<byte[], byte[]> 
consumer) {
+        consumer.updatePartitions(
             GLOBAL_STORE_TOPIC_NAME,
             Collections.singletonList(new PartitionInfo(
                 GLOBAL_STORE_TOPIC_NAME,
                 0,
                 null,
                 new Node[0],
                 new Node[0])));
-        
mockConsumer.updateBeginningOffsets(Collections.singletonMap(topicPartition, 
0L));
-        mockConsumer.updateEndOffsets(Collections.singletonMap(topicPartition, 
0L));
-        mockConsumer.assign(Collections.singleton(topicPartition));
+        
consumer.updateBeginningOffsets(Collections.singletonMap(topicPartition, 0L));
+        consumer.updateEndOffsets(Collections.singletonMap(topicPartition, 
0L));
+        consumer.assign(Collections.singleton(topicPartition));
+    }
+
+    private static void interruptOnNextPoll(final MockConsumer<byte[], byte[]> 
consumer) {
+        // the exception is created on the polling thread, since its 
constructor sets the interrupt status
+        consumer.schedulePollTask(() -> {
+            throw new InterruptException(new InterruptedException());
+        });
+    }
+
+    private MockConsumer<byte[], byte[]> 
consumerRecordingInterruptStatusOnClose(final AtomicBoolean interruptedOnClose) 
{
+        final MockConsumer<byte[], byte[]> consumer = new 
MockConsumer<>(AutoOffsetResetStrategy.NONE.name()) {
+            @Override
+            public void close() {
+                interruptedOnClose.set(Thread.currentThread().isInterrupted());
+                super.close();
+            }
+        };
+        initializeConsumer(consumer);
+        return consumer;
+    }
+
+    private GlobalStreamThread globalStreamThread(final MockConsumer<byte[], 
byte[]> consumer) {
+        return new GlobalStreamThread(

Review Comment:
   Renamed to `newGlobalStreamThread`.



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

Reply via email to