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

 ##########
 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));
 
 Review comment:
   Here we test that that initially only input vertices are scheduled. I would 
remove the assertion here because we should test only one concept per test, and 
this assertion is already covered in `testStartScheduling()`:
   
   
https://softwareengineering.stackexchange.com/questions/7823/is-it-ok-to-have-multiple-asserts-in-a-single-unit-test

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