rkhachatryan commented on a change in pull request #11491: 
[FLINK-16513][checkpointing] Unaligned checkpoints: checkpoint metadata
URL: https://github.com/apache/flink/pull/11491#discussion_r400370230
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/ChannelStateNoRescalingPartitionerTest.java
 ##########
 @@ -0,0 +1,129 @@
+/*
+ * 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;
+
+import org.apache.flink.runtime.checkpoint.channel.InputChannelInfo;
+import org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo;
+import org.apache.flink.runtime.jobgraph.OperatorID;
+import org.apache.flink.runtime.state.AbstractChannelStateHandle;
+import org.apache.flink.runtime.state.InputChannelStateHandle;
+import org.apache.flink.runtime.state.ResultSubpartitionStateHandle;
+import org.apache.flink.runtime.state.testutils.EmptyStreamStateHandle;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Function;
+
+import static java.util.Collections.singletonList;
+import static 
org.apache.flink.runtime.checkpoint.StateAssignmentOperation.channelStateNonRescalingRepartitioner;
+import static org.apache.flink.runtime.checkpoint.StateObjectCollection.empty;
+import static 
org.apache.flink.runtime.checkpoint.StateObjectCollection.singleton;
+import static org.junit.Assert.fail;
+
+/**
+ * Simple test for
+ * {@link 
org.apache.flink.runtime.checkpoint.StateAssignmentOperation#channelStateNonRescalingRepartitioner
 channelStateNonRescalingRepartitioner}.
+ * It checks whether partitioner fails or not using property-based approach.
+ */
+@RunWith(Parameterized.class)
+public class ChannelStateNoRescalingPartitionerTest {
+
+       @Parameters
+       public static Collection<Object[]> parameters() {
+               List<Object[]> params = new ArrayList<>();
+               int[] parLevels = {1, 2};
+               int[] offsetSizes = {0, 1, 2};
+               final List<Function<OperatorSubtaskState, ?>> extractors = 
Arrays.asList(
+                       OperatorSubtaskState::getInputChannelState,
+                       OperatorSubtaskState::getResultSubpartitionState
+               );
+               for (int oldParallelism : parLevels) {
+                       for (int newParallelism : parLevels) {
+                               for (int offsetSize : offsetSizes) {
+                                       for (Function<OperatorSubtaskState, ?> 
stateExtractor : extractors) {
+                                               params.add(new 
Object[]{oldParallelism, newParallelism, offsetSize, stateExtractor});
 
 Review comment:
   Parameters here reflect the parameters of the tested method. 
   To me, this generation of all combinations with nested loops is simpler than 
having parameters generated in different places. I've added a comment to make 
it clear.
   
   > why we need offsetSize here?
   
   No offsets means no state so re-scaling with no offsets should be allowed.

----------------------------------------------------------------
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

Reply via email to