AHeise commented on a change in pull request #14608:
URL: https://github.com/apache/flink/pull/14608#discussion_r555342871



##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/MailboxOperatorTest.java
##########
@@ -67,35 +69,35 @@ public void testAvoidTaskStarvation() throws Exception {
                 .chain(
                         new OperatorID(),
                         new 
ReplicatingMailOperatorFactory(maxProcessingElements),
-                        IntSerializer.INSTANCE)
+                        LongSerializer.INSTANCE)
                 .finish();
 
         testHarness.invoke();
         testHarness.waitForTaskRunning();
 
         for (int i = 0; i < maxProcessingElements; i++) {
-            testHarness.processElement(new StreamRecord<>(0));
+            testHarness.processElement(new StreamRecord<>(0L));
+            Thread.sleep(1);
         }
 
         testHarness.endInput();
         testHarness.waitForTaskCompletion();
 
+        List<Long> numMailsProcessed =
+                testHarness.getOutput().stream()
+                        .map(element -> ((StreamRecord<Long>) 
element).getValue())
+                        .collect(Collectors.toList());
         // with each input two mails should be processed, one of each operator 
in the chain
-        List<Integer> expected = new ArrayList<>();
+        // verify that at least one mail was processed between inputs
+        List<Matcher> minExpectedMatchers = new ArrayList<>();
         for (int i = 0; i < maxProcessingElements; i++) {
-            expected.add(i * 2);
+            minExpectedMatchers.add(Matchers.greaterThanOrEqualTo(i * 2L));
         }
-        List<Integer> numMailsProcessed =
-                testHarness.getOutput().stream()
-                        .map(element -> ((StreamRecord<Integer>) 
element).getValue())
-                        .collect(Collectors.toList());
-        assertThat(numMailsProcessed, is(expected));
+        assertThat(numMailsProcessed, hasItems(minExpectedMatchers.toArray(new 
Matcher[0])));

Review comment:
       The result actually captured the number of mails processed, which is [0; 
2; 4] in most cases.




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


Reply via email to