yunfengzhou-hub commented on code in PR #24667:
URL: https://github.com/apache/flink/pull/24667#discussion_r1575597004
##########
flink-runtime/src/test/java/org/apache/flink/runtime/asyncprocessing/AsyncExecutionControllerTest.java:
##########
@@ -346,6 +337,63 @@ public void testSyncPoint() {
recordContext2.release();
}
+ @Test
+ void testBufferTimeout() throws InterruptedException {
+ batchSize = 5;
+ timeout = 1000;
+ setup();
+ Runnable userCode = () -> valueState.asyncValue();
+
+ // ------------ basic timeout -------------------
+ for (int i = 0; i < batchSize - 1; i++) {
+ String record = String.format("key%d-r%d", i, i);
+ String key = String.format("key%d", batchSize + i);
+ RecordContext<String> recordContext = aec.buildContext(record,
key);
+ aec.setCurrentContext(recordContext);
+ userCode.run();
+ }
+ assertThat(aec.timeoutFlag.get()).isFalse();
+ assertThat(aec.currentScheduledFuture.isDone()).isFalse();
+ assertThat(aec.inFlightRecordNum.get()).isEqualTo(batchSize - 1);
+
assertThat(aec.stateRequestsBuffer.activeQueueSize()).isEqualTo(batchSize - 1);
+ assertThat(aec.stateRequestsBuffer.blockingQueueSize()).isEqualTo(0);
+
+ Thread.sleep(timeout + 100);
Review Comment:
It might be better to avoid using `Thread.sleep` in test cases, as it may
increase the duration of CI and behave as flaky tests. How about introduce a
`TestScheduledThreadPoolExecutor` so we can control when each step is
triggered? An example of this is
`org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor`.
--
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]