Java Code Examples for org.apache.flink.streaming.runtime.tasks.StreamTaskTestHarness#waitForTaskCompletion()
The following examples show how to use
org.apache.flink.streaming.runtime.tasks.StreamTaskTestHarness#waitForTaskCompletion() .
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: StreamSourceOperatorWatermarksTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testMaxWatermarkIsForwardedLastForFiniteSource() throws Exception { StreamSource<String, ?> sourceOperator = new StreamSource<>(new FiniteSource(true)); StreamTaskTestHarness<String> testHarness = setupSourceStreamTask(sourceOperator, BasicTypeInfo.STRING_TYPE_INFO); testHarness.invoke(); testHarness.waitForTaskCompletion(); ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>(); expectedOutput.add(new StreamRecord<>("Hello")); expectedOutput.add(Watermark.MAX_WATERMARK); TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput()); }
Example 2
Source File: StreamSourceOperatorWatermarksTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testNoMaxWatermarkOnImmediateCancel() throws Exception { StreamSource<String, ?> sourceOperator = new StreamSource<>(new InfiniteSource<>()); StreamTaskTestHarness<String> testHarness = setupSourceStreamTask( sourceOperator, BasicTypeInfo.STRING_TYPE_INFO, true); testHarness.invoke(); try { testHarness.waitForTaskCompletion(); fail("should throw an exception"); } catch (Throwable t) { if (!ExceptionUtils.findThrowable(t, CancelTaskException.class).isPresent()) { throw t; } } assertTrue(testHarness.getOutput().isEmpty()); }
Example 3
Source File: StreamSourceOperatorWatermarksTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testNoMaxWatermarkOnAsyncCancel() throws Exception { StreamSource<String, ?> sourceOperator = new StreamSource<>(new InfiniteSource<>()); StreamTaskTestHarness<String> testHarness = setupSourceStreamTask(sourceOperator, BasicTypeInfo.STRING_TYPE_INFO); testHarness.invoke(); testHarness.waitForTaskRunning(); Thread.sleep(200); testHarness.getTask().cancel(); try { testHarness.waitForTaskCompletion(); } catch (Throwable t) { if (!ExceptionUtils.findThrowable(t, CancelTaskException.class).isPresent()) { throw t; } } assertTrue(testHarness.getOutput().isEmpty()); }
Example 4
Source File: StreamIterationHeadTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testIterationHeadWatermarkEmission() throws Exception { StreamTaskTestHarness<Integer> harness = new StreamTaskTestHarness<>( StreamIterationHead::new, BasicTypeInfo.INT_TYPE_INFO); harness.setupOutputForSingletonOperatorChain(); harness.getStreamConfig().setIterationId("1"); harness.getStreamConfig().setIterationWaitTime(1); harness.invoke(); harness.waitForTaskCompletion(); assertEquals(1, harness.getOutput().size()); assertEquals(new Watermark(Long.MAX_VALUE), harness.getOutput().peek()); }
Example 5
Source File: StreamIterationHeadTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testIterationHeadWatermarkEmission() throws Exception { StreamTaskTestHarness<Integer> harness = new StreamTaskTestHarness<>( StreamIterationHead::new, BasicTypeInfo.INT_TYPE_INFO); harness.setupOutputForSingletonOperatorChain(); harness.getStreamConfig().setIterationId("1"); harness.getStreamConfig().setIterationWaitTime(1); harness.invoke(); harness.waitForTaskCompletion(); assertEquals(1, harness.getOutput().size()); assertEquals(new Watermark(Long.MAX_VALUE), harness.getOutput().peek()); }
Example 6
Source File: StreamIterationHeadTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testIterationHeadWatermarkEmission() throws Exception { StreamTaskTestHarness<Integer> harness = new StreamTaskTestHarness<>( StreamIterationHead::new, BasicTypeInfo.INT_TYPE_INFO); harness.setupOutputForSingletonOperatorChain(); harness.getStreamConfig().setIterationId("1"); harness.getStreamConfig().setIterationWaitTime(1); harness.invoke(); harness.waitForTaskCompletion(); assertEquals(1, harness.getOutput().size()); assertEquals(new Watermark(Long.MAX_VALUE), harness.getOutput().peek()); }
Example 7
Source File: StreamTaskTimerTest.java From flink with Apache License 2.0 | 5 votes |
private void stopTestHarness(StreamTaskTestHarness<?> testHarness, long timeout) throws Exception { testHarness.endInput(); testHarness.waitForTaskCompletion(); // thread needs to die in time long deadline = System.currentTimeMillis() + timeout; while (StreamTask.TRIGGER_THREAD_GROUP.activeCount() > 0 && System.currentTimeMillis() < deadline) { Thread.sleep(10); } assertEquals("Trigger timer thread did not properly shut down", 0, StreamTask.TRIGGER_THREAD_GROUP.activeCount()); }
Example 8
Source File: StreamSourceOperatorWatermarksTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testEmitMaxWatermarkForFiniteSource() throws Exception { StreamSource<String, ?> sourceOperator = new StreamSource<>(new FiniteSource()); StreamTaskTestHarness<String> testHarness = setupSourceStreamTask(sourceOperator, BasicTypeInfo.STRING_TYPE_INFO); testHarness.invoke(); testHarness.waitForTaskCompletion(); assertEquals(1, testHarness.getOutput().size()); assertEquals(Watermark.MAX_WATERMARK, testHarness.getOutput().peek()); }