Skip to content

Commit

Permalink
[FLINK-23419][streaming] Fixed the condition in testNextFirstCheckpoi…
Browse files Browse the repository at this point in the history
…ntBarrierOvertakesCancellationBarrier in order to make the test more stable
  • Loading branch information
akalash committed Jul 20, 2021
1 parent cf9c6bd commit 363f244
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -357,13 +356,28 @@ public void testNextFirstCheckpointBarrierOvertakesCancellationBarrier() throws
ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler();
inputGate = createCheckpointedInputGate(2, sequence, validator);

for (BufferOrEvent boe : sequence) {
assertEquals(boe, inputGate.pollNext().get());
Thread.sleep(10);
}
long alignmentTime = validator.lastAlignmentDurationNanos.get() / 1_000_000;
assertThat(alignmentTime, greaterThan(0L));
assertThat(alignmentTime, lessThan(30L));
// Checkpoint 1
assertEquals(sequence[0], inputGate.pollNext().get());

long beforeSecondCheckpointStartTime = System.nanoTime();
// Checkpoint 2
assertEquals(sequence[1], inputGate.pollNext().get());
long afterSecondCheckpointStartTime = System.nanoTime();
// Cancellation checkpoint 1
assertEquals(sequence[2], inputGate.pollNext().get());
long beforeSecondCheckpointEndTime = System.nanoTime();
// Finishing checkpoint 2
assertEquals(sequence[3], inputGate.pollNext().get());
long afterSecondCheckpointEndTime = System.nanoTime();

long alignmentTime = validator.lastAlignmentDurationNanos.get();
assertThat(
alignmentTime,
greaterThanOrEqualTo(
beforeSecondCheckpointEndTime - afterSecondCheckpointStartTime));
assertThat(
alignmentTime,
lessThanOrEqualTo(afterSecondCheckpointEndTime - beforeSecondCheckpointStartTime));
}

@Test
Expand Down

0 comments on commit 363f244

Please sign in to comment.