lucliu1108 commented on code in PR #20693:
URL: https://github.com/apache/kafka/pull/20693#discussion_r2501453430
##########
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
Review Comment:
i'm thinking about the time elapsed between initialTime to
time.milliseconds() . should be a little bit more than 5 seconds (but that
difference is trivial)
--
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]