eaglewatcherwb commented on a change in pull request #8309: [FLINK-12229] 
[runtime] Implement LazyFromSourcesScheduling Strategy
URL: https://github.com/apache/flink/pull/8309#discussion_r285010865
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/strategy/LazyFromSourcesSchedulingStrategyTest.java
 ##########
 @@ -0,0 +1,230 @@
+/*
+ * 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.scheduler.strategy;
+
+import org.apache.flink.runtime.execution.ExecutionState;
+import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.util.TestLogger;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.api.common.InputDependencyConstraint.ALL;
+import static 
org.apache.flink.runtime.io.network.partition.ResultPartitionType.PIPELINED;
+import static 
org.apache.flink.runtime.scheduler.strategy.StrategyTestUtil.getExecutionVertexIdsFromDeployOptions;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit tests for {@link LazyFromSourcesSchedulingStrategy}.
+ */
+public class LazyFromSourcesSchedulingStrategyTest extends TestLogger {
+
+       private TestingSchedulerOperations testingSchedulerOperation = new 
TestingSchedulerOperations();
+
+       /**
+        * Tests that when start scheduling lazy from sources scheduling 
strategy will start input vertices in scheduling topology.
+        */
+       @Test
+       public void testStartScheduling() {
+               final TestingSchedulingTopology testingSchedulingTopology = new 
TestingSchedulingTopology();
+
+               final List<TestingSchedulingExecutionVertex> producers = 
testingSchedulingTopology.addExecutionVertices().finish();
+               final List<TestingSchedulingExecutionVertex> consumers = 
testingSchedulingTopology.addExecutionVertices().finish();
+               testingSchedulingTopology.connectAllToAll(producers, 
consumers).finish();
+
+               startScheduling(testingSchedulingTopology);
+
+               assertThat(testingSchedulerOperation, 
hasScheduledVertices(producers));
+       }
+
+       /**
+        * Tests that when restart tasks will only schedule input ready 
vertices in given ones.
+        */
+       @Test
+       public void testRestartTasks() {
+               final TestingSchedulingTopology testingSchedulingTopology = new 
TestingSchedulingTopology();
+
+               final List<TestingSchedulingExecutionVertex> producers = 
testingSchedulingTopology.addExecutionVertices().finish();
+               final List<TestingSchedulingExecutionVertex> consumers = 
testingSchedulingTopology.addExecutionVertices().finish();
+               testingSchedulingTopology.connectAllToAll(producers, 
consumers).finish();
+
+               LazyFromSourcesSchedulingStrategy schedulingStrategy = 
startScheduling(testingSchedulingTopology);
+
+               assertThat(testingSchedulerOperation, 
hasScheduledVertices(producers));
+
+               Set<ExecutionVertexID> verticesToRestart = 
producers.stream().map(TestingSchedulingExecutionVertex::getId)
+                       .collect(Collectors.toSet());
+               verticesToRestart.addAll(consumers.stream().map(
+                       
TestingSchedulingExecutionVertex::getId).collect(Collectors.toSet()));
+
+               schedulingStrategy.restartTasks(verticesToRestart);
+               assertThat(testingSchedulerOperation, 
hasScheduledVertices(producers));
+       }
+
 
 Review comment:
   `SchedulingIntermediateDataSetManager` is a good idea, I will wrap up all 
the  `SchedulingIntermediateDataSet` functions into 
`SchedulingIntermediateDataSetManager`.
   
   ~~For `restartTasks` tests I expand `ProducerConsumerConnectionBuilder`, It 
seems easy to combine various `ResultPartitionType` and `ResultPartitionState` 
user cases. Thus I still add tests in `LazyFromSourcesSchedulingStrategyTest`, 
what do you think?~~
   Edit: Misunderstood the class meaning, I will do like that.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to