pnowojski commented on a change in pull request #14573: URL: https://github.com/apache/flink/pull/14573#discussion_r553274705
########## File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java ########## @@ -1241,9 +1241,60 @@ public void testProcessWithAvailableOutput() throws Exception { } } + /** + * In this weird construct, we are: + * + * <ul> + * <li>1. We start a thread, which will... + * <li>2. ... sleep for X ms, and enqueue another mail, that will... + * <li>3. ... sleep for Y ms, and make the output available again + * </ul> + * + * <p>2nd step is to check that back pressure or idle counter is at least X. In the last 3rd + * step, we test whether this counter was paused for the duration of processing mails. + */ + private static class WaitingThread extends Thread { + private final MailboxExecutor executor; + private final RunnableWithException resumeTask; + private final long sleepTimeInsideMail; + private final long sleepTimeOutsideMail; + + public WaitingThread( + MailboxExecutor executor, + RunnableWithException resumeTask, + long sleepTimeInsideMail, + long sleepTimeOutsideMail) { + this.executor = executor; + this.resumeTask = resumeTask; + this.sleepTimeInsideMail = sleepTimeInsideMail; + this.sleepTimeOutsideMail = sleepTimeOutsideMail; + } + + @Override + public void run() { + try { + Thread.sleep(sleepTimeOutsideMail); + } catch (InterruptedException e) { + e.printStackTrace(); Review comment: Spurious wake-up affects waiting on POSIX/UNIX conditions. Here someone would have to send SIGINT to the thread/process. If we ignore interrupt, that would most likely fail the test (actual sleep times would be less then expected, failing assertion). I've changed the code a bit, to pass/re-throw the `InterruptedException` from the mailbox thread. ---------------------------------------------------------------- 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: us...@infra.apache.org