use of org.apache.flink.streaming.runtime.io.checkpointing.AlignedCheckpointsTest.CheckpointExceptionMatcher in project flink by apache.
the class StreamTaskCancellationBarrierTest method testDeclineCallOnCancelBarrierOneInput.
/**
* This test verifies (for onw input tasks) that the Stream tasks react the following way to
* receiving a checkpoint cancellation barrier: - send a "decline checkpoint" notification out
* (to the JobManager) - emit a cancellation barrier downstream.
*/
@Test
public void testDeclineCallOnCancelBarrierOneInput() throws Exception {
OneInputStreamTaskTestHarness<String, String> testHarness = new OneInputStreamTaskTestHarness<>(OneInputStreamTask::new, 1, 2, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
testHarness.setupOutputForSingletonOperatorChain();
StreamConfig streamConfig = testHarness.getStreamConfig();
StreamMap<String, String> mapOperator = new StreamMap<>(new IdentityMap());
streamConfig.setStreamOperator(mapOperator);
streamConfig.setOperatorID(new OperatorID());
StreamMockEnvironment environment = spy(testHarness.createEnvironment());
// start the task
testHarness.invoke(environment);
testHarness.waitForTaskRunning();
// emit cancellation barriers
testHarness.processEvent(new CancelCheckpointMarker(2L), 0, 1);
testHarness.processEvent(new CancelCheckpointMarker(2L), 0, 0);
testHarness.waitForInputProcessing();
// the decline call should go to the coordinator
verify(environment, times(1)).declineCheckpoint(eq(2L), argThat(new CheckpointExceptionMatcher(CheckpointFailureReason.CHECKPOINT_DECLINED_ON_CANCELLATION_BARRIER)));
// a cancellation barrier should be downstream
Object result = testHarness.getOutput().poll();
assertNotNull("nothing emitted", result);
assertTrue("wrong type emitted", result instanceof CancelCheckpointMarker);
assertEquals("wrong checkpoint id", 2L, ((CancelCheckpointMarker) result).getCheckpointId());
// cancel and shutdown
testHarness.endInput();
testHarness.waitForTaskCompletion();
}
Aggregations