AHeise commented on a change in pull request #11515: [FLINK-16744][task] implement channel state persistence for unaligned checkpoints URL: https://github.com/apache/flink/pull/11515#discussion_r405009883
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/channel/ChannelStateWriteRequestExecutorImplTest.java ########## @@ -0,0 +1,203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.checkpoint.channel; + +import org.apache.flink.util.ExceptionUtils; +import org.apache.flink.util.function.BiConsumerWithException; + +import org.junit.Test; + +import javax.annotation.Nonnull; + +import java.io.IOException; +import java.util.Arrays; +import java.util.concurrent.LinkedBlockingDeque; + +import static org.apache.flink.runtime.checkpoint.channel.ChannelStateWriteRequestDispatcher.NO_OP; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * {@link ChannelStateWriteRequestExecutorImpl} test. + */ +public class ChannelStateWriteRequestExecutorImplTest { + + @Test(expected = IllegalStateException.class) + public void testCloseAfterSubmit() throws Exception { + testCloseAfterSubmit(ChannelStateWriteRequestExecutor::submit); + } + + @Test(expected = IllegalStateException.class) + public void testCloseAfterSubmitPriority() throws Exception { + testCloseAfterSubmit(ChannelStateWriteRequestExecutor::submitPriority); + } + + @Test + public void testSubmitFailure() throws Exception { + testSubmitFailure(ChannelStateWriteRequestExecutor::submit); + } + + @Test + public void testSubmitPriorityFailure() throws Exception { + testSubmitFailure(ChannelStateWriteRequestExecutor::submitPriority); + } + + private void testCloseAfterSubmit(BiConsumerWithException<ChannelStateWriteRequestExecutor, ChannelStateWriteRequest, Exception> requestFun) throws Exception { + WorkerClosingDeque closingDeque = new WorkerClosingDeque(); + ChannelStateWriteRequestExecutorImpl worker = new ChannelStateWriteRequestExecutorImpl(NO_OP, closingDeque); + closingDeque.setWorker(worker); + TestWriteRequest request = new TestWriteRequest(); + requestFun.accept(worker, request); + assertTrue(closingDeque.isEmpty()); + assertFalse(request.isCancelled()); + } + + private void testSubmitFailure(BiConsumerWithException<ChannelStateWriteRequestExecutor, ChannelStateWriteRequest, Exception> submitAction) throws Exception { + TestWriteRequest request = new TestWriteRequest(); + LinkedBlockingDeque<ChannelStateWriteRequest> deque = new LinkedBlockingDeque<>(); + try { + submitAction.accept(new ChannelStateWriteRequestExecutorImpl(NO_OP, deque), request); + } catch (IllegalStateException e) { + // expected: executor not started; + return; + } finally { + assertTrue(request.cancelled); + assertTrue(deque.isEmpty()); + } + throw new RuntimeException("expected exception not thrown"); + } + + @Test + @SuppressWarnings("CallToThreadRun") Review comment: See my previous comment on suppressions. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services