You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/06/22 07:58:34 UTC

[GitHub] [flink] zhuzhurk commented on a diff in pull request #20039: [FLINK-28133][runtime] Rework DefaultScheduler to directly deploy executions

zhuzhurk commented on code in PR #20039:
URL: https://github.com/apache/flink/pull/20039#discussion_r903414036


##########
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/DefaultExecutionDeployerTest.java:
##########
@@ -0,0 +1,388 @@
+/*
+ * 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;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter;
+import org.apache.flink.runtime.executiongraph.Execution;
+import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
+import org.apache.flink.runtime.executiongraph.ExecutionGraph;
+import org.apache.flink.runtime.executiongraph.ExecutionVertex;
+import org.apache.flink.runtime.executiongraph.TestingDefaultExecutionGraphBuilder;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+import org.apache.flink.runtime.io.network.partition.TestingJobMasterPartitionTracker;
+import org.apache.flink.runtime.jobgraph.DistributionPattern;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.jobgraph.JobGraphTestUtils;
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID;
+import org.apache.flink.runtime.shuffle.TestingShuffleMaster;
+import org.apache.flink.runtime.testtasks.NoOpInvokable;
+import org.apache.flink.util.ExecutorUtils;
+import org.apache.flink.util.IterableUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Fail.fail;
+
+/** Tests for {@link DefaultExecutionDeployer}. */
+public class DefaultExecutionDeployerTest extends TestLogger {
+
+    private ScheduledExecutorService executor;
+    private ComponentMainThreadExecutor mainThreadExecutor;
+    private TestExecutionOperationsDecorator testExecutionOperations;
+    private ExecutionVertexVersioner executionVertexVersioner;
+    private TestExecutionSlotAllocator testExecutionSlotAllocator;
+    private TestingShuffleMaster shuffleMaster;
+    private TestingJobMasterPartitionTracker partitionTracker;
+    private Time partitionRegistrationTimeout;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        executor = Executors.newSingleThreadScheduledExecutor();
+        mainThreadExecutor = ComponentMainThreadExecutorServiceAdapter.forMainThread();
+        testExecutionOperations =
+                new TestExecutionOperationsDecorator(
+                        new ExecutionOperations() {
+                            @Override
+                            public void deploy(Execution execution) {}
+
+                            @Override
+                            public CompletableFuture<?> cancel(Execution execution) {
+                                return null;
+                            }
+
+                            @Override
+                            public void markFailed(Execution execution, Throwable cause) {}
+                        });
+        executionVertexVersioner = new ExecutionVertexVersioner();
+        testExecutionSlotAllocator = new TestExecutionSlotAllocator();
+        shuffleMaster = new TestingShuffleMaster();
+        partitionTracker = new TestingJobMasterPartitionTracker();
+        partitionRegistrationTimeout = Time.milliseconds(5000);
+    }
+
+    @AfterEach
+    public void tearDown() throws Exception {
+        if (executor != null) {
+            ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, executor);
+        }
+    }
+
+    @Test
+    public void testDeployTasks() throws Exception {
+        final JobGraph jobGraph = singleNonParallelJobVertexJobGraph();
+        final ExecutionGraph executionGraph = createExecutionGraph(jobGraph);
+        final ExecutionDeployer executionDeployer = createExecutionDeployer(executionGraph);
+
+        deployTasks(executionDeployer, executionGraph);
+
+        assertThat(testExecutionOperations.getDeployedExecutions())
+                .contains(getAnyExecution(executionGraph).getAttemptId());
+    }
+
+    @Test
+    public void testDeployTasksOnlyIfAllSlotRequestsAreFulfilled() throws Exception {
+        final JobGraph jobGraph = singleJobVertexJobGraph(4);
+        final ExecutionGraph executionGraph = createExecutionGraph(jobGraph);
+        final ExecutionDeployer executionDeployer = createExecutionDeployer(executionGraph);
+
+        testExecutionSlotAllocator.disableAutoCompletePendingRequests();
+
+        deployTasks(executionDeployer, executionGraph);
+
+        assertThat(testExecutionOperations.getDeployedExecutions()).hasSize(0);
+
+        final ExecutionAttemptID attemptId = getAnyExecution(executionGraph).getAttemptId();
+        testExecutionSlotAllocator.completePendingRequest(attemptId);
+        assertThat(testExecutionOperations.getDeployedExecutions()).hasSize(0);
+
+        testExecutionSlotAllocator.completePendingRequests();
+        assertThat(testExecutionOperations.getDeployedExecutions()).hasSize(4);
+    }
+
+    @Test
+    public void testDeploymentFailures() throws Exception {
+        final JobGraph jobGraph = singleNonParallelJobVertexJobGraph();
+
+        testExecutionOperations.enableFailDeploy();
+
+        final ExecutionGraph executionGraph = createExecutionGraph(jobGraph);
+        final ExecutionDeployer executionDeployer = createExecutionDeployer(executionGraph);
+        deployTasks(executionDeployer, executionGraph);
+
+        assertThat(testExecutionOperations.getFailedExecutions())
+                .contains(getAnyExecution(executionGraph).getAttemptId());
+    }
+
+    @Test
+    public void testSlotAllocationTimeout() throws Exception {
+        final JobGraph jobGraph = singleJobVertexJobGraph(2);
+
+        testExecutionSlotAllocator.disableAutoCompletePendingRequests();
+
+        final ExecutionGraph executionGraph = createExecutionGraph(jobGraph);
+        final ExecutionDeployer executionDeployer = createExecutionDeployer(executionGraph);
+        deployTasks(executionDeployer, executionGraph);
+
+        assertThat(testExecutionSlotAllocator.getPendingRequests().keySet()).hasSize(2);
+
+        final ExecutionAttemptID attemptId = getAnyExecution(executionGraph).getAttemptId();
+        testExecutionSlotAllocator.timeoutPendingRequest(attemptId);
+
+        assertThat(testExecutionOperations.getFailedExecutions()).contains(attemptId);

Review Comment:
   Ok.



##########
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/DefaultExecutionDeployerTest.java:
##########
@@ -0,0 +1,388 @@
+/*
+ * 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;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter;
+import org.apache.flink.runtime.executiongraph.Execution;
+import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
+import org.apache.flink.runtime.executiongraph.ExecutionGraph;
+import org.apache.flink.runtime.executiongraph.ExecutionVertex;
+import org.apache.flink.runtime.executiongraph.TestingDefaultExecutionGraphBuilder;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+import org.apache.flink.runtime.io.network.partition.TestingJobMasterPartitionTracker;
+import org.apache.flink.runtime.jobgraph.DistributionPattern;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.jobgraph.JobGraphTestUtils;
+import org.apache.flink.runtime.jobgraph.JobVertex;
+import org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID;
+import org.apache.flink.runtime.shuffle.TestingShuffleMaster;
+import org.apache.flink.runtime.testtasks.NoOpInvokable;
+import org.apache.flink.util.ExecutorUtils;
+import org.apache.flink.util.IterableUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Fail.fail;
+
+/** Tests for {@link DefaultExecutionDeployer}. */
+public class DefaultExecutionDeployerTest extends TestLogger {

Review Comment:
   Ok.



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

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org