Search in sources :

Example 6 with MockEnvironmentBuilder

use of org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder in project flink by apache.

the class InputFormatSourceFunctionTest method testFormatLifecycle.

private void testFormatLifecycle(final boolean midCancel) throws Exception {
    final int noOfSplits = 5;
    final int cancelAt = 2;
    final LifeCycleTestInputFormat format = new LifeCycleTestInputFormat();
    final InputFormatSourceFunction<Integer> reader = new InputFormatSourceFunction<>(format, TypeInformation.of(Integer.class));
    try (MockEnvironment environment = new MockEnvironmentBuilder().setTaskName("no").setManagedMemorySize(4 * MemoryManager.DEFAULT_PAGE_SIZE).build()) {
        reader.setRuntimeContext(new MockRuntimeContext(format, noOfSplits, environment));
        Assert.assertTrue(!format.isConfigured);
        Assert.assertTrue(!format.isInputFormatOpen);
        Assert.assertTrue(!format.isSplitOpen);
        reader.open(new Configuration());
        Assert.assertTrue(format.isConfigured);
        TestSourceContext ctx = new TestSourceContext(reader, format, midCancel, cancelAt);
        reader.run(ctx);
        int splitsSeen = ctx.getSplitsSeen();
        Assert.assertTrue(midCancel ? splitsSeen == cancelAt : splitsSeen == noOfSplits);
        // we have exhausted the splits so the
        // format and splits should be closed by now
        Assert.assertTrue(!format.isSplitOpen);
        Assert.assertTrue(!format.isInputFormatOpen);
    }
}
Also used : MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) Configuration(org.apache.flink.configuration.Configuration) MockEnvironment(org.apache.flink.runtime.operators.testutils.MockEnvironment)

Example 7 with MockEnvironmentBuilder

use of org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder in project flink by apache.

the class SourceOperatorLatencyMetricsTest method testLatencyMarkEmission.

private void testLatencyMarkEmission(boolean shouldExpectLatencyMarkers, Configuration taskManagerConfig, ExecutionConfig executionConfig) throws Exception {
    try (SourceOperatorTestHarness testHarness = new SourceOperatorTestHarness(new SourceOperatorFactory(new MockSource(Boundedness.CONTINUOUS_UNBOUNDED, 1), WatermarkStrategy.noWatermarks()), new MockEnvironmentBuilder().setTaskManagerRuntimeInfo(new TestingTaskManagerRuntimeInfo(taskManagerConfig)).setExecutionConfig(executionConfig).build())) {
        testHarness.open();
        testHarness.setup();
        for (long processingTime = 0; processingTime <= MAX_PROCESSING_TIME; processingTime++) {
            testHarness.getProcessingTimeService().setCurrentTime(processingTime);
            testHarness.emitNext();
        }
        List<LatencyMarker> expectedOutput = new ArrayList<>();
        if (!shouldExpectLatencyMarkers) {
            assertTrue(testHarness.getOutput().isEmpty());
        } else {
            expectedOutput.add(new LatencyMarker(1, testHarness.getOperator().getOperatorID(), 0));
            for (long markedTime = LATENCY_MARK_INTERVAL; markedTime <= MAX_PROCESSING_TIME; markedTime += LATENCY_MARK_INTERVAL) {
                expectedOutput.add(new LatencyMarker(markedTime, testHarness.getOperator().getOperatorID(), 0));
            }
            assertThat((Collection<Object>) testHarness.getOutput(), contains(expectedOutput.toArray()));
        }
    }
}
Also used : MockSource(org.apache.flink.api.connector.source.mocks.MockSource) MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) TestingTaskManagerRuntimeInfo(org.apache.flink.runtime.util.TestingTaskManagerRuntimeInfo) SourceOperatorTestHarness(org.apache.flink.streaming.util.SourceOperatorTestHarness) LatencyMarker(org.apache.flink.streaming.runtime.streamrecord.LatencyMarker) ArrayList(java.util.ArrayList) SourceOperatorFactory(org.apache.flink.streaming.api.operators.SourceOperatorFactory)

Example 8 with MockEnvironmentBuilder

use of org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder in project flink by apache.

the class StreamSourceOperatorLatencyMetricsTest method testLatencyMarkEmission.

private void testLatencyMarkEmission(int numberLatencyMarkers, OperatorSetupOperation operatorSetup) throws Exception {
    final List<StreamElement> output = new ArrayList<>();
    final TestProcessingTimeService testProcessingTimeService = new TestProcessingTimeService();
    testProcessingTimeService.setCurrentTime(0L);
    final List<Long> processingTimes = Arrays.asList(1L, 10L, 11L, 21L, maxProcessingTime);
    // regular stream source operator
    final StreamSource<Long, ProcessingTimeServiceSource> operator = new StreamSource<>(new ProcessingTimeServiceSource(testProcessingTimeService, processingTimes));
    operatorSetup.setupSourceOperator(operator, testProcessingTimeService);
    // run and wait to be stopped
    OperatorChain<?, ?> operatorChain = new RegularOperatorChain<>(operator.getContainingTask(), StreamTask.createRecordWriterDelegate(operator.getOperatorConfig(), new MockEnvironmentBuilder().build()));
    try {
        operator.run(new Object(), new CollectorOutput<>(output), operatorChain);
        operator.finish();
    } finally {
        operatorChain.close();
    }
    assertEquals(numberLatencyMarkers, output.size());
    long timestamp = 0L;
    int expectedLatencyIndex = 0;
    int i = 0;
    // verify that its only latency markers
    for (; i < numberLatencyMarkers; i++) {
        StreamElement se = output.get(i);
        Assert.assertTrue(se.isLatencyMarker());
        Assert.assertEquals(operator.getOperatorID(), se.asLatencyMarker().getOperatorId());
        Assert.assertEquals(0, se.asLatencyMarker().getSubtaskIndex());
        // as a result of which we never emit both 10 and 11
        while (timestamp > processingTimes.get(expectedLatencyIndex)) {
            expectedLatencyIndex++;
        }
        Assert.assertEquals(processingTimes.get(expectedLatencyIndex).longValue(), se.asLatencyMarker().getMarkedTime());
        timestamp += latencyMarkInterval;
    }
}
Also used : MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) StreamSource(org.apache.flink.streaming.api.operators.StreamSource) ArrayList(java.util.ArrayList) StreamElement(org.apache.flink.streaming.runtime.streamrecord.StreamElement) TestProcessingTimeService(org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService) RegularOperatorChain(org.apache.flink.streaming.runtime.tasks.RegularOperatorChain)

Example 9 with MockEnvironmentBuilder

use of org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder in project flink by apache.

the class InputProcessorUtilTest method testCreateCheckpointedMultipleInputGate.

@Test
public void testCreateCheckpointedMultipleInputGate() throws Exception {
    try (CloseableRegistry registry = new CloseableRegistry()) {
        MockEnvironment environment = new MockEnvironmentBuilder().build();
        MockStreamTask streamTask = new MockStreamTaskBuilder(environment).build();
        StreamConfig streamConfig = new StreamConfig(environment.getJobConfiguration());
        streamConfig.setCheckpointMode(CheckpointingMode.EXACTLY_ONCE);
        streamConfig.setUnalignedCheckpointsEnabled(true);
        // First input gate has index larger than the second
        List<IndexedInputGate>[] inputGates = new List[] { Collections.singletonList(getGate(1, 4)), Collections.singletonList(getGate(0, 2)) };
        CheckpointBarrierHandler barrierHandler = InputProcessorUtil.createCheckpointBarrierHandler(streamTask, streamConfig, new TestSubtaskCheckpointCoordinator(new MockChannelStateWriter()), streamTask.getName(), inputGates, Collections.emptyList(), new SyncMailboxExecutor(), new TestProcessingTimeService());
        CheckpointedInputGate[] checkpointedMultipleInputGate = InputProcessorUtil.createCheckpointedMultipleInputGate(new SyncMailboxExecutor(), inputGates, environment.getMetricGroup().getIOMetricGroup(), barrierHandler, streamConfig);
        for (CheckpointedInputGate checkpointedInputGate : checkpointedMultipleInputGate) {
            registry.registerCloseable(checkpointedInputGate);
        }
        List<IndexedInputGate> allInputGates = Arrays.stream(inputGates).flatMap(gates -> gates.stream()).collect(Collectors.toList());
        for (IndexedInputGate inputGate : allInputGates) {
            for (int channelId = 0; channelId < inputGate.getNumberOfInputChannels(); channelId++) {
                barrierHandler.processBarrier(new CheckpointBarrier(1, 42, CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, CheckpointStorageLocationReference.getDefault())), new InputChannelInfo(inputGate.getGateIndex(), channelId), false);
            }
        }
        assertTrue(barrierHandler.getAllBarriersReceivedFuture(1).isDone());
    }
}
Also used : MockStreamTaskBuilder(org.apache.flink.streaming.util.MockStreamTaskBuilder) MockChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.MockChannelStateWriter) Arrays(java.util.Arrays) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) CheckpointingMode(org.apache.flink.streaming.api.CheckpointingMode) CloseableRegistry(org.apache.flink.core.fs.CloseableRegistry) TestSubtaskCheckpointCoordinator(org.apache.flink.streaming.runtime.tasks.TestSubtaskCheckpointCoordinator) MockStreamTask(org.apache.flink.streaming.util.MockStreamTask) MockEnvironment(org.apache.flink.runtime.operators.testutils.MockEnvironment) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) MockChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.MockChannelStateWriter) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) SyncMailboxExecutor(org.apache.flink.runtime.mailbox.SyncMailboxExecutor) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) CheckpointType(org.apache.flink.runtime.checkpoint.CheckpointType) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelBuilder(org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder) MockStreamTaskBuilder(org.apache.flink.streaming.util.MockStreamTaskBuilder) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) TestProcessingTimeService(org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService) Collectors(java.util.stream.Collectors) List(java.util.List) CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) IndexedInputGate(org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate) Collections(java.util.Collections) MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) SyncMailboxExecutor(org.apache.flink.runtime.mailbox.SyncMailboxExecutor) MockStreamTask(org.apache.flink.streaming.util.MockStreamTask) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) IndexedInputGate(org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate) CloseableRegistry(org.apache.flink.core.fs.CloseableRegistry) TestSubtaskCheckpointCoordinator(org.apache.flink.streaming.runtime.tasks.TestSubtaskCheckpointCoordinator) CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) MockEnvironment(org.apache.flink.runtime.operators.testutils.MockEnvironment) TestProcessingTimeService(org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService) List(java.util.List) Test(org.junit.Test)

Example 10 with MockEnvironmentBuilder

use of org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder in project flink by apache.

the class StreamTaskTest method testQuiesceOfMailboxRightBeforeSubmittingActionViaTimerService.

@Test
public void testQuiesceOfMailboxRightBeforeSubmittingActionViaTimerService() throws Exception {
    // given: the stream task with configured handle async exception.
    AtomicBoolean submitThroughputFail = new AtomicBoolean();
    MockEnvironment mockEnvironment = new MockEnvironmentBuilder().build();
    final UnAvailableTestInputProcessor inputProcessor = new UnAvailableTestInputProcessor();
    RunningTask<StreamTask<?, ?>> task = runTask(() -> new MockStreamTaskBuilder(mockEnvironment).setHandleAsyncException((str, t) -> submitThroughputFail.set(true)).setStreamInputProcessor(inputProcessor).build());
    waitTaskIsRunning(task.streamTask, task.invocationFuture);
    TimerService timerService = task.streamTask.systemTimerService;
    MailboxExecutor mainMailboxExecutor = task.streamTask.mailboxProcessor.getMainMailboxExecutor();
    CountDownLatch stoppingMailboxLatch = new CountDownLatch(1);
    timerService.registerTimer(timerService.getCurrentProcessingTime(), (time) -> {
        stoppingMailboxLatch.await();
        // The time to the start 'afterInvoke' inside of mailbox.
        // 'afterInvoke' won't finish until this execution won't finish so it is
        // impossible to wait on latch or something else.
        Thread.sleep(5);
        mainMailboxExecutor.submit(() -> {
        }, "test");
    });
    // when: Calling the quiesce for mailbox and finishing the timer service.
    mainMailboxExecutor.submit(() -> {
        stoppingMailboxLatch.countDown();
        task.streamTask.afterInvoke();
    }, "test").get();
    // then: the exception handle wasn't invoked because the such situation is expected.
    assertFalse(submitThroughputFail.get());
    // Correctly shutdown the stream task to avoid hanging.
    inputProcessor.availabilityProvider.getUnavailableToResetAvailable().complete(null);
}
Also used : MockStreamTaskBuilder(org.apache.flink.streaming.util.MockStreamTaskBuilder) InternalTimeServiceManager(org.apache.flink.streaming.api.operators.InternalTimeServiceManager) NettyShuffleDescriptorBuilder(org.apache.flink.runtime.util.NettyShuffleDescriptorBuilder) ArgumentMatchers.nullable(org.mockito.ArgumentMatchers.nullable) TaskLocalStateStoreImpl(org.apache.flink.runtime.state.TaskLocalStateStoreImpl) Collections.singletonList(java.util.Collections.singletonList) CheckpointException(org.apache.flink.runtime.checkpoint.CheckpointException) Arrays.asList(java.util.Arrays.asList) Duration(java.time.Duration) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) AvailabilityTestResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.AvailabilityTestResultPartitionWriter) FunctionWithException(org.apache.flink.util.function.FunctionWithException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) FatalExitExceptionHandler(org.apache.flink.util.FatalExitExceptionHandler) Matchers.any(org.mockito.Matchers.any) CountDownLatch(java.util.concurrent.CountDownLatch) AsynchronousException(org.apache.flink.runtime.taskmanager.AsynchronousException) Assert.assertFalse(org.junit.Assert.assertFalse) DummyEnvironment(org.apache.flink.runtime.operators.testutils.DummyEnvironment) Mockito.mock(org.mockito.Mockito.mock) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter) Mockito.spy(org.mockito.Mockito.spy) Answer(org.mockito.stubbing.Answer) OptionalLong(java.util.OptionalLong) MAX_PRIORITY(org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailbox.MAX_PRIORITY) Output(org.apache.flink.streaming.api.operators.Output) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CheckpointableKeyedStateBackend(org.apache.flink.runtime.state.CheckpointableKeyedStateBackend) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) MailboxExecutor(org.apache.flink.api.common.operators.MailboxExecutor) ExecutionState(org.apache.flink.runtime.execution.ExecutionState) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) MockStreamConfig(org.apache.flink.streaming.util.MockStreamConfig) StreamOperator(org.apache.flink.streaming.api.operators.StreamOperator) ExecutionException(java.util.concurrent.ExecutionException) Mockito.never(org.mockito.Mockito.never) JobID(org.apache.flink.api.common.JobID) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) CheckpointStreamFactory(org.apache.flink.runtime.state.CheckpointStreamFactory) Assert.assertEquals(org.junit.Assert.assertEquals) TaskStateManagerImpl(org.apache.flink.runtime.state.TaskStateManagerImpl) TestTaskBuilder(org.apache.flink.runtime.taskmanager.TestTaskBuilder) SystemClock(org.apache.flink.util.clock.SystemClock) ThroughputCalculator(org.apache.flink.runtime.throughput.ThroughputCalculator) ShuffleEnvironment(org.apache.flink.runtime.shuffle.ShuffleEnvironment) ObjectInputStream(java.io.ObjectInputStream) ExceptionUtils(org.apache.flink.util.ExceptionUtils) FunctionSnapshotContext(org.apache.flink.runtime.state.FunctionSnapshotContext) TimerGauge(org.apache.flink.runtime.metrics.TimerGauge) BasicTypeInfo(org.apache.flink.api.common.typeinfo.BasicTypeInfo) ChainingStrategy(org.apache.flink.streaming.api.operators.ChainingStrategy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CheckpointStorageLocationReference.getDefault(org.apache.flink.runtime.state.CheckpointStorageLocationReference.getDefault) Matchers.eq(org.mockito.Matchers.eq) BUFFER_DEBLOAT_ENABLED(org.apache.flink.configuration.TaskManagerOptions.BUFFER_DEBLOAT_ENABLED) TaskStateSnapshot(org.apache.flink.runtime.checkpoint.TaskStateSnapshot) CheckpointType(org.apache.flink.runtime.checkpoint.CheckpointType) BUFFER_DEBLOAT_THRESHOLD_PERCENTAGES(org.apache.flink.configuration.TaskManagerOptions.BUFFER_DEBLOAT_THRESHOLD_PERCENTAGES) MockStreamTaskBuilder(org.apache.flink.streaming.util.MockStreamTaskBuilder) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) Preconditions(org.apache.flink.util.Preconditions) AbstractKeyedStateBackend(org.apache.flink.runtime.state.AbstractKeyedStateBackend) CloseableIterable(org.apache.flink.util.CloseableIterable) DEFAULT_OUTPUT_FLUSH_THREAD_NAME(org.apache.flink.runtime.io.network.api.writer.RecordWriter.DEFAULT_OUTPUT_FLUSH_THREAD_NAME) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) CheckpointResponder(org.apache.flink.runtime.taskmanager.CheckpointResponder) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData) Assert.assertThrows(org.junit.Assert.assertThrows) CoreMatchers.not(org.hamcrest.CoreMatchers.not) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) OperatorStreamStateHandle(org.apache.flink.runtime.state.OperatorStreamStateHandle) ArgumentCaptor(org.mockito.ArgumentCaptor) StreamRecord(org.apache.flink.streaming.runtime.streamrecord.StreamRecord) StreamTaskStateInitializer(org.apache.flink.streaming.api.operators.StreamTaskStateInitializer) RichParallelSourceFunction(org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction) StreamMap(org.apache.flink.streaming.api.operators.StreamMap) MockEnvironment(org.apache.flink.runtime.operators.testutils.MockEnvironment) StreamInputProcessor(org.apache.flink.streaming.runtime.io.StreamInputProcessor) ExecutorService(java.util.concurrent.ExecutorService) RunnableFuture(java.util.concurrent.RunnableFuture) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) Configuration(org.apache.flink.configuration.Configuration) StreamOperatorParameters(org.apache.flink.streaming.api.operators.StreamOperatorParameters) MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) Mockito.when(org.mockito.Mockito.when) Consumer(java.util.function.Consumer) STATE_BACKEND(org.apache.flink.configuration.StateBackendOptions.STATE_BACKEND) ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) IndexedInputGate(org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate) TaskExecutionState(org.apache.flink.runtime.taskmanager.TaskExecutionState) ProcessingTimeCallback(org.apache.flink.api.common.operators.ProcessingTimeService.ProcessingTimeCallback) StreamSource(org.apache.flink.streaming.api.operators.StreamSource) TaskIOMetricGroup(org.apache.flink.runtime.metrics.groups.TaskIOMetricGroup) Arrays(java.util.Arrays) AbstractStreamOperatorFactory(org.apache.flink.streaming.api.operators.AbstractStreamOperatorFactory) CheckpointListener(org.apache.flink.api.common.state.CheckpointListener) OperatorStateBackend(org.apache.flink.runtime.state.OperatorStateBackend) TypeSerializer(org.apache.flink.api.common.typeutils.TypeSerializer) CancelTaskException(org.apache.flink.runtime.execution.CancelTaskException) Executors(java.util.concurrent.Executors) StopMode(org.apache.flink.runtime.io.network.api.StopMode) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) SnapshotType(org.apache.flink.runtime.checkpoint.SnapshotType) TaskStateManager(org.apache.flink.runtime.state.TaskStateManager) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) OneInputStreamOperator(org.apache.flink.streaming.api.operators.OneInputStreamOperator) StateHandleID(org.apache.flink.runtime.state.StateHandleID) RunnableWithException(org.apache.flink.util.function.RunnableWithException) STRING_TYPE_INFO(org.apache.flink.api.common.typeinfo.BasicTypeInfo.STRING_TYPE_INFO) ArrayList(java.util.ArrayList) MEMORY_SEGMENT_SIZE(org.apache.flink.configuration.TaskManagerOptions.MEMORY_SEGMENT_SIZE) Mockito.timeout(org.mockito.Mockito.timeout) OperatorSnapshotFutures(org.apache.flink.streaming.api.operators.OperatorSnapshotFutures) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SourceFunction(org.apache.flink.streaming.api.functions.source.SourceFunction) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) ReadableConfig(org.apache.flink.configuration.ReadableConfig) Matchers.lessThan(org.hamcrest.Matchers.lessThan) ChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter) Nullable(javax.annotation.Nullable) SnapshotResult(org.apache.flink.runtime.state.SnapshotResult) TimeCharacteristic(org.apache.flink.streaming.api.TimeCharacteristic) MailboxDefaultAction(org.apache.flink.streaming.runtime.tasks.mailbox.MailboxDefaultAction) FSDataInputStream(org.apache.flink.core.fs.FSDataInputStream) StreamStateHandle(org.apache.flink.runtime.state.StreamStateHandle) InMemoryStateChangelogStorage(org.apache.flink.runtime.state.changelog.inmemory.InMemoryStateChangelogStorage) AbstractStreamOperator(org.apache.flink.streaming.api.operators.AbstractStreamOperator) Task(org.apache.flink.runtime.taskmanager.Task) SubtaskState(org.apache.flink.runtime.checkpoint.SubtaskState) TestingUncaughtExceptionHandler(org.apache.flink.util.concurrent.TestingUncaughtExceptionHandler) Assert(org.junit.Assert) CoreMatchers(org.hamcrest.CoreMatchers) CheckpointMetricsBuilder(org.apache.flink.runtime.checkpoint.CheckpointMetricsBuilder) SavepointType(org.apache.flink.runtime.checkpoint.SavepointType) SharedStateRegistry(org.apache.flink.runtime.state.SharedStateRegistry) TimeoutException(java.util.concurrent.TimeoutException) StreamTaskUtil.waitTaskIsRunning(org.apache.flink.streaming.util.StreamTaskUtil.waitTaskIsRunning) PartitionDescriptorBuilder(org.apache.flink.runtime.shuffle.PartitionDescriptorBuilder) StringSerializer(org.apache.flink.api.common.typeutils.base.StringSerializer) MapFunction(org.apache.flink.api.common.functions.MapFunction) BUFFER_DEBLOAT_PERIOD(org.apache.flink.configuration.TaskManagerOptions.BUFFER_DEBLOAT_PERIOD) DataInputStatus(org.apache.flink.streaming.runtime.io.DataInputStatus) TaskManagerActions(org.apache.flink.runtime.taskmanager.TaskManagerActions) TestLogger(org.apache.flink.util.TestLogger) Assert.fail(org.junit.Assert.fail) MockStateBackend(org.apache.flink.runtime.state.ttl.mock.MockStateBackend) KeyGroupRange(org.apache.flink.runtime.state.KeyGroupRange) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) CheckpointedFunction(org.apache.flink.streaming.api.checkpoint.CheckpointedFunction) BUFFER_DEBLOAT_TARGET(org.apache.flink.configuration.TaskManagerOptions.BUFFER_DEBLOAT_TARGET) ExpectedTestException(org.apache.flink.runtime.operators.testutils.ExpectedTestException) FunctionInitializationContext(org.apache.flink.runtime.state.FunctionInitializationContext) KeyedStateHandle(org.apache.flink.runtime.state.KeyedStateHandle) OperatorSubtaskState(org.apache.flink.runtime.checkpoint.OperatorSubtaskState) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) AbstractStateBackend(org.apache.flink.runtime.state.AbstractStateBackend) StateObjectCollection.singleton(org.apache.flink.runtime.checkpoint.StateObjectCollection.singleton) List(java.util.List) ResultPartitionDeploymentDescriptor(org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor) KeyGroupStatePartitionStreamProvider(org.apache.flink.runtime.state.KeyGroupStatePartitionStreamProvider) Optional(java.util.Optional) StateBackendFactory(org.apache.flink.runtime.state.StateBackendFactory) CheckpointMetrics(org.apache.flink.runtime.checkpoint.CheckpointMetrics) Environment(org.apache.flink.runtime.execution.Environment) SupplierWithException(org.apache.flink.util.function.SupplierWithException) BiConsumerWithException(org.apache.flink.util.function.BiConsumerWithException) StatePartitionStreamProvider(org.apache.flink.runtime.state.StatePartitionStreamProvider) NoOpTaskManagerActions(org.apache.flink.runtime.taskmanager.NoOpTaskManagerActions) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) SavepointFormatType(org.apache.flink.core.execution.SavepointFormatType) TaskInvokable(org.apache.flink.runtime.jobgraph.tasks.TaskInvokable) UNKNOWN_TASK_CHECKPOINT_NOTIFICATION_FAILURE(org.apache.flink.runtime.checkpoint.CheckpointFailureReason.UNKNOWN_TASK_CHECKPOINT_NOTIFICATION_FAILURE) TestingTaskManagerRuntimeInfo(org.apache.flink.runtime.util.TestingTaskManagerRuntimeInfo) Matchers.anyLong(org.mockito.Matchers.anyLong) OperatorStateHandle(org.apache.flink.runtime.state.OperatorStateHandle) ExpectedException(org.junit.rules.ExpectedException) InputGate(org.apache.flink.runtime.io.network.partition.consumer.InputGate) Preconditions.checkState(org.apache.flink.util.Preconditions.checkState) StreamOperatorStateContext(org.apache.flink.streaming.api.operators.StreamOperatorStateContext) Matchers(org.hamcrest.Matchers) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) DoneFuture(org.apache.flink.runtime.state.DoneFuture) Rule(org.junit.Rule) Closeable(java.io.Closeable) Collections(java.util.Collections) StateInitializationContext(org.apache.flink.runtime.state.StateInitializationContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MockEnvironmentBuilder(org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder) MockEnvironment(org.apache.flink.runtime.operators.testutils.MockEnvironment) MailboxExecutor(org.apache.flink.api.common.operators.MailboxExecutor) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

MockEnvironmentBuilder (org.apache.flink.runtime.operators.testutils.MockEnvironmentBuilder)21 MockEnvironment (org.apache.flink.runtime.operators.testutils.MockEnvironment)15 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)7 Configuration (org.apache.flink.configuration.Configuration)7 IOException (java.io.IOException)5 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)5 CheckpointException (org.apache.flink.runtime.checkpoint.CheckpointException)5 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)5 ExpectedTestException (org.apache.flink.runtime.operators.testutils.ExpectedTestException)5 MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)5 Arrays (java.util.Arrays)4 ExecutionException (java.util.concurrent.ExecutionException)4 TimeoutException (java.util.concurrent.TimeoutException)4 JobID (org.apache.flink.api.common.JobID)4 CloseableRegistry (org.apache.flink.core.fs.CloseableRegistry)4 CancelTaskException (org.apache.flink.runtime.execution.CancelTaskException)4 SnapshotResult (org.apache.flink.runtime.state.SnapshotResult)4 StateInitializationContext (org.apache.flink.runtime.state.StateInitializationContext)4 AsynchronousException (org.apache.flink.runtime.taskmanager.AsynchronousException)4