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

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/strategy/LazyFromSourcesSchedulingStrategyTest.java
 ##########
 @@ -0,0 +1,194 @@
+/*
+ * 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.api.common.InputDependencyConstraint;
+import org.apache.flink.runtime.execution.ExecutionState;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+import org.apache.flink.runtime.jobgraph.DistributionPattern;
+import org.apache.flink.runtime.jobgraph.IntermediateDataSet;
+import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.scheduler.ExecutionVertexDeploymentOption;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit test for {@link LazyFromSourcesSchedulingStrategy}.
+ */
+public class LazyFromSourcesSchedulingStrategyTest extends TestLogger {
+
+       /**
+        * Tests that when start scheduling lazy from sources scheduling 
strategy will start input vertices in scheduling topology.
+        */
+       @Test
+       public void testStartScheduling() {
+               JobVertex jobVertex1 = new JobVertex("vertex#1");
+               JobVertex jobVertex2 = new JobVertex("vertex#2");
+               JobGraph graph = new JobGraph(jobVertex1, jobVertex2);
+               jobVertex2.connectNewDataSetAsInput(jobVertex1, 
DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING);
+
+               TestingSchedulingTopology schedulingTopology = new 
TestingSchedulingTopology();
+
+               for (int i = 0; i < 3; i++) {
+                       schedulingTopology.addSchedulingVertex(new 
TestingSchedulingVertex(jobVertex1.getID(), i));
+                       schedulingTopology.addSchedulingVertex(new 
TestingSchedulingVertex(jobVertex2.getID(), i));
+               }
+
+               TestingSchedulerOperation testingSchedulerOperation = new 
TestingSchedulerOperation();
+               LazyFromSourcesSchedulingStrategy schedulingStrategy = new 
LazyFromSourcesSchedulingStrategy(
+                       testingSchedulerOperation,
+                       schedulingTopology,
+                       graph);
+
+               schedulingStrategy.startScheduling();
+
+               assertEquals(3, 
testingSchedulerOperation.getScheduledVertices().size());
+       }
+
+       /**
+        * Tests that when on execution state change will start available 
downstream vertices.
+        * vertex#0    vertex#1
+        *       \     /
+        *        \   /
+        *         \ /
+        *  (BLOCKING, ALL)
+        *     vertex#3      vertex#2
+        *           \        /
+        *            \      /
+        *             \    /
+        *          (BLOCKING, ANY)
+        *             vertex#4
+        *                |
+        *                |
+        *                |
+        *            (PIPELINED)
+        *             vertex#5
+        */
+       @Test
+       public void testOnExecutionStateChange() {
+               TestingSchedulingTopology schedulingTopology = new 
TestingSchedulingTopology();
 
 Review comment:
   I think this method is a bit too long. It could be split into more units 
(see Clean Code by Robert C Martin, Chapter 3).

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