Java Code Examples for org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness#prepareSnapshotPreBarrier()

The following examples show how to use org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness#prepareSnapshotPreBarrier() . 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: PythonScalarFunctionOperatorTestBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWatermarkProcessedOnFinishBundle() throws Exception {
	Configuration conf = new Configuration();
	conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
	OneInputStreamOperatorTestHarness<IN, OUT> testHarness = getTestHarness(conf);
	long initialTime = 0L;
	ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();

	testHarness.open();

	testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));
	testHarness.processWatermark(initialTime + 2);
	assertOutputEquals("Watermark has been processed", expectedOutput, testHarness.getOutput());

	// checkpoint trigger finishBundle
	testHarness.prepareSnapshotPreBarrier(0L);

	expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L)));
	expectedOutput.add(new Watermark(initialTime + 2));

	assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());

	testHarness.close();
}
 
Example 2
Source File: PythonTableFunctionOperatorTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testFinishBundleTriggeredOnCheckpoint() throws Exception {
	Configuration conf = new Configuration();
	conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
	OneInputStreamOperatorTestHarness<IN, OUT> testHarness = getTestHarness(conf, JoinRelType.INNER);

	long initialTime = 0L;
	ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();

	testHarness.open();

	testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));

	// checkpoint trigger finishBundle
	testHarness.prepareSnapshotPreBarrier(0L);

	expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L, 0L)));

	assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());

	testHarness.close();
}
 
Example 3
Source File: PythonScalarFunctionOperatorTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testFinishBundleTriggeredOnCheckpoint() throws Exception {
	Configuration conf = new Configuration();
	conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
	OneInputStreamOperatorTestHarness<IN, OUT> testHarness = getTestHarness(conf);

	long initialTime = 0L;
	ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();

	testHarness.open();

	testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));

	// checkpoint trigger finishBundle
	testHarness.prepareSnapshotPreBarrier(0L);

	expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L)));

	assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());

	testHarness.close();
}