mjsax commented on code in PR #20693:
URL: https://github.com/apache/kafka/pull/20693#discussion_r2501374450


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##########
@@ -1599,6 +1605,70 @@ public void shouldBeRecordIdlingTimeIfSuspended() {
         assertThat("task is not idling", 
task.timeCurrentIdlingStarted().isEmpty());
     }
 
+    @Test
+    public void shouldLogNotReadyWhenStaleAfterThreshold() throws Exception {
+        when(stateManager.taskId()).thenReturn(taskId);
+        when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+        
+        task = createStatelessTask(createConfig("100"));
+        task.initializeIfNeeded();
+        task.completeRestoration(noOpResetter -> { });
+
+        task.addRecords(partition1, 
singleton(getConsumerRecordWithOffsetAsTimestamp(partition1, 0)));
+        
+        // Set lastNotReadyLogTime to simulate staleness
+        final Field lastNotReadyLogTimeField = 
StreamTask.class.getDeclaredField("lastNotReadyLogTime");
+        lastNotReadyLogTimeField.setAccessible(true);
+
+        try (final LogCaptureAppender streamTaskAppender = 
LogCaptureAppender.createAndRegister(StreamTask.class);
+             final LogCaptureAppender partitionGroupAppender = 
LogCaptureAppender.createAndRegister(PartitionGroup.class)) {
+            
+            // Enable TRACE logging for PartitionGroup to capture the "ready 
for processing" message
+            partitionGroupAppender.setClassLogger(PartitionGroup.class, 
Level.TRACE);
+            
+            // Set lastNotReadyLogTime to 100 seconds ago
+            final long initialTime = time.milliseconds();
+            lastNotReadyLogTimeField.set(task, Optional.of(initialTime - 
100_000L));
+            
+            // Advance time by approximately 5 seconds
+            long newTime = time.milliseconds() + 5_000L;

Review Comment:
   If we want to be "exactly, why not use `19_999L` here, ie, exactly 1ms 
before the cut-off point?



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