rkhachatryan commented on a change in pull request #14968:
URL: https://github.com/apache/flink/pull/14968#discussion_r580140016
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/SourceStreamTaskTest.java
##########
@@ -856,4 +887,41 @@ private void output(String record) {
output.collect(new StreamRecord<>(record));
}
}
+
+ /**
+ * This source sleeps a little bit before processing cancellation and
records whether it was
+ * interrupted by the {@link SourceStreamTask} or not.
+ */
+ private static class WasInterruptedTestingSource implements
SourceFunction<String> {
+ private static final int MAX_POST_CANCEL_ITERATIONS = 100;
+ private static final long serialVersionUID = 1L;
+ private volatile boolean running;
+
+ public static boolean wasInterrupted;
+
+ @Override
+ public void run(SourceContext<String> ctx) throws Exception {
+ wasInterrupted = false;
+ try {
+ int postCancelIterations = 0;
+ while (running || postCancelIterations <
MAX_POST_CANCEL_ITERATIONS) {
Review comment:
I mean't to add in `testStopWithSavepointShouldNotInterruptTheSource`
after
```
Future<Void> notifyFuture =
harness.streamTask.notifyCheckpointCompleteAsync(checkpointId);```
```
something like this:
```
while (harness.streamTask.isMailboxLoopRunning() && !notifyFuture.isDone()) {
harness.streamTask.runMailboxStep();
}
notifyFuture.get();
// interruption, if any, must have happened before
WasInterruptedTestingSource.allowExit();
```
This allows to detect otherwise undetected interrupt (ignore `interrupt`
flag in `cancelTask()` and sleep 1s).
As it allows to drop the loop in the source, complexity seems the same or a
bit lower.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]