Java Code Examples for org.apache.flink.streaming.util.TestHarnessUtil#assertNoLateRecords()
The following examples show how to use
org.apache.flink.streaming.util.TestHarnessUtil#assertNoLateRecords() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntervalJoinOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testRestoreFromSnapshot() throws Exception { // config int lowerBound = -1; boolean lowerBoundInclusive = true; int upperBound = 1; boolean upperBoundInclusive = true; // create first test harness OperatorSubtaskState handles; List<StreamRecord<Tuple2<TestElem, TestElem>>> expectedOutput; try (TestHarness testHarness = createTestHarness( lowerBound, lowerBoundInclusive, upperBound, upperBoundInclusive )) { testHarness.setup(); testHarness.open(); // process elements with first test harness testHarness.processElement1(createStreamRecord(1, "lhs")); testHarness.processWatermark1(new Watermark(1)); testHarness.processElement2(createStreamRecord(1, "rhs")); testHarness.processWatermark2(new Watermark(1)); testHarness.processElement1(createStreamRecord(2, "lhs")); testHarness.processWatermark1(new Watermark(2)); testHarness.processElement2(createStreamRecord(2, "rhs")); testHarness.processWatermark2(new Watermark(2)); testHarness.processElement1(createStreamRecord(3, "lhs")); testHarness.processWatermark1(new Watermark(3)); testHarness.processElement2(createStreamRecord(3, "rhs")); testHarness.processWatermark2(new Watermark(3)); // snapshot and validate output handles = testHarness.snapshot(0, 0); testHarness.close(); expectedOutput = Lists.newArrayList( streamRecordOf(1, 1), streamRecordOf(1, 2), streamRecordOf(2, 1), streamRecordOf(2, 2), streamRecordOf(2, 3), streamRecordOf(3, 2), streamRecordOf(3, 3) ); TestHarnessUtil.assertNoLateRecords(testHarness.getOutput()); assertOutput(expectedOutput, testHarness.getOutput()); } try (TestHarness newTestHarness = createTestHarness( lowerBound, lowerBoundInclusive, upperBound, upperBoundInclusive )) { // create new test harness from snapshpt newTestHarness.setup(); newTestHarness.initializeState(handles); newTestHarness.open(); // process elements newTestHarness.processElement1(createStreamRecord(4, "lhs")); newTestHarness.processWatermark1(new Watermark(4)); newTestHarness.processElement2(createStreamRecord(4, "rhs")); newTestHarness.processWatermark2(new Watermark(4)); // assert expected output expectedOutput = Lists.newArrayList( streamRecordOf(3, 4), streamRecordOf(4, 3), streamRecordOf(4, 4) ); TestHarnessUtil.assertNoLateRecords(newTestHarness.getOutput()); assertOutput(expectedOutput, newTestHarness.getOutput()); } }
Example 2
Source File: IntervalJoinOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public JoinTestBuilder noLateRecords() { TestHarnessUtil.assertNoLateRecords(this.testHarness.getOutput()); return this; }
Example 3
Source File: IntervalJoinOperatorTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testRestoreFromSnapshot() throws Exception { // config int lowerBound = -1; boolean lowerBoundInclusive = true; int upperBound = 1; boolean upperBoundInclusive = true; // create first test harness OperatorSubtaskState handles; List<StreamRecord<Tuple2<TestElem, TestElem>>> expectedOutput; try (TestHarness testHarness = createTestHarness( lowerBound, lowerBoundInclusive, upperBound, upperBoundInclusive )) { testHarness.setup(); testHarness.open(); // process elements with first test harness testHarness.processElement1(createStreamRecord(1, "lhs")); testHarness.processWatermark1(new Watermark(1)); testHarness.processElement2(createStreamRecord(1, "rhs")); testHarness.processWatermark2(new Watermark(1)); testHarness.processElement1(createStreamRecord(2, "lhs")); testHarness.processWatermark1(new Watermark(2)); testHarness.processElement2(createStreamRecord(2, "rhs")); testHarness.processWatermark2(new Watermark(2)); testHarness.processElement1(createStreamRecord(3, "lhs")); testHarness.processWatermark1(new Watermark(3)); testHarness.processElement2(createStreamRecord(3, "rhs")); testHarness.processWatermark2(new Watermark(3)); // snapshot and validate output handles = testHarness.snapshot(0, 0); testHarness.close(); expectedOutput = Lists.newArrayList( streamRecordOf(1, 1), streamRecordOf(1, 2), streamRecordOf(2, 1), streamRecordOf(2, 2), streamRecordOf(2, 3), streamRecordOf(3, 2), streamRecordOf(3, 3) ); TestHarnessUtil.assertNoLateRecords(testHarness.getOutput()); assertOutput(expectedOutput, testHarness.getOutput()); } try (TestHarness newTestHarness = createTestHarness( lowerBound, lowerBoundInclusive, upperBound, upperBoundInclusive )) { // create new test harness from snapshpt newTestHarness.setup(); newTestHarness.initializeState(handles); newTestHarness.open(); // process elements newTestHarness.processElement1(createStreamRecord(4, "lhs")); newTestHarness.processWatermark1(new Watermark(4)); newTestHarness.processElement2(createStreamRecord(4, "rhs")); newTestHarness.processWatermark2(new Watermark(4)); // assert expected output expectedOutput = Lists.newArrayList( streamRecordOf(3, 4), streamRecordOf(4, 3), streamRecordOf(4, 4) ); TestHarnessUtil.assertNoLateRecords(newTestHarness.getOutput()); assertOutput(expectedOutput, newTestHarness.getOutput()); } }
Example 4
Source File: IntervalJoinOperatorTest.java From flink with Apache License 2.0 | 4 votes |
public JoinTestBuilder noLateRecords() { TestHarnessUtil.assertNoLateRecords(this.testHarness.getOutput()); return this; }
Example 5
Source File: IntervalJoinOperatorTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testRestoreFromSnapshot() throws Exception { // config int lowerBound = -1; boolean lowerBoundInclusive = true; int upperBound = 1; boolean upperBoundInclusive = true; // create first test harness OperatorSubtaskState handles; List<StreamRecord<Tuple2<TestElem, TestElem>>> expectedOutput; try (TestHarness testHarness = createTestHarness( lowerBound, lowerBoundInclusive, upperBound, upperBoundInclusive )) { testHarness.setup(); testHarness.open(); // process elements with first test harness testHarness.processElement1(createStreamRecord(1, "lhs")); testHarness.processWatermark1(new Watermark(1)); testHarness.processElement2(createStreamRecord(1, "rhs")); testHarness.processWatermark2(new Watermark(1)); testHarness.processElement1(createStreamRecord(2, "lhs")); testHarness.processWatermark1(new Watermark(2)); testHarness.processElement2(createStreamRecord(2, "rhs")); testHarness.processWatermark2(new Watermark(2)); testHarness.processElement1(createStreamRecord(3, "lhs")); testHarness.processWatermark1(new Watermark(3)); testHarness.processElement2(createStreamRecord(3, "rhs")); testHarness.processWatermark2(new Watermark(3)); // snapshot and validate output handles = testHarness.snapshot(0, 0); testHarness.close(); expectedOutput = Lists.newArrayList( streamRecordOf(1, 1), streamRecordOf(1, 2), streamRecordOf(2, 1), streamRecordOf(2, 2), streamRecordOf(2, 3), streamRecordOf(3, 2), streamRecordOf(3, 3) ); TestHarnessUtil.assertNoLateRecords(testHarness.getOutput()); assertOutput(expectedOutput, testHarness.getOutput()); } try (TestHarness newTestHarness = createTestHarness( lowerBound, lowerBoundInclusive, upperBound, upperBoundInclusive )) { // create new test harness from snapshpt newTestHarness.setup(); newTestHarness.initializeState(handles); newTestHarness.open(); // process elements newTestHarness.processElement1(createStreamRecord(4, "lhs")); newTestHarness.processWatermark1(new Watermark(4)); newTestHarness.processElement2(createStreamRecord(4, "rhs")); newTestHarness.processWatermark2(new Watermark(4)); // assert expected output expectedOutput = Lists.newArrayList( streamRecordOf(3, 4), streamRecordOf(4, 3), streamRecordOf(4, 4) ); TestHarnessUtil.assertNoLateRecords(newTestHarness.getOutput()); assertOutput(expectedOutput, newTestHarness.getOutput()); } }
Example 6
Source File: IntervalJoinOperatorTest.java From flink with Apache License 2.0 | 4 votes |
public JoinTestBuilder noLateRecords() { TestHarnessUtil.assertNoLateRecords(this.testHarness.getOutput()); return this; }