azagrebin commented on a change in pull request #13641: URL: https://github.com/apache/flink/pull/13641#discussion_r532697063
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphSchedulingTest.java ########## @@ -1,637 +0,0 @@ -/* - * 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.executiongraph; - -import org.apache.flink.api.common.JobID; -import org.apache.flink.api.common.JobStatus; -import org.apache.flink.api.common.time.Time; -import org.apache.flink.configuration.Configuration; -import org.apache.flink.metrics.groups.UnregisteredMetricsGroup; -import org.apache.flink.runtime.blob.VoidBlobWriter; -import org.apache.flink.runtime.checkpoint.StandaloneCheckpointRecoveryFactory; -import org.apache.flink.runtime.clusterframework.types.AllocationID; -import org.apache.flink.runtime.clusterframework.types.ResourceID; -import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter; -import org.apache.flink.runtime.execution.ExecutionState; -import org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy; -import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway; -import org.apache.flink.runtime.instance.SimpleSlotContext; -import org.apache.flink.runtime.io.network.partition.NoOpJobMasterPartitionTracker; -import org.apache.flink.runtime.io.network.partition.ResultPartitionType; -import org.apache.flink.runtime.jobgraph.DistributionPattern; -import org.apache.flink.runtime.jobgraph.JobGraph; -import org.apache.flink.runtime.jobgraph.JobVertex; -import org.apache.flink.runtime.jobgraph.ScheduleMode; -import org.apache.flink.runtime.jobmanager.scheduler.Locality; -import org.apache.flink.runtime.jobmanager.slots.DummySlotOwner; -import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway; -import org.apache.flink.runtime.jobmanager.slots.TestingSlotOwner; -import org.apache.flink.runtime.jobmaster.LogicalSlot; -import org.apache.flink.runtime.jobmaster.SlotOwner; -import org.apache.flink.runtime.jobmaster.SlotRequestId; -import org.apache.flink.runtime.jobmaster.TestingLogicalSlot; -import org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder; -import org.apache.flink.runtime.jobmaster.slotpool.SingleLogicalSlot; -import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider; -import org.apache.flink.runtime.shuffle.NettyShuffleMaster; -import org.apache.flink.runtime.taskmanager.TaskManagerLocation; -import org.apache.flink.runtime.testtasks.NoOpInvokable; -import org.apache.flink.runtime.testutils.DirectScheduledExecutorService; -import org.apache.flink.util.FlinkException; -import org.apache.flink.util.TestLogger; - -import org.junit.After; -import org.junit.Test; - -import javax.annotation.Nonnull; - -import java.net.InetAddress; -import java.util.Set; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; - -/** - * Tests for the scheduling of the execution graph. This tests that - * for example the order of deployments is correct and that bulk slot allocation - * works properly. - */ -public class ExecutionGraphSchedulingTest extends TestLogger { Review comment: Not sure whether we test how slot release/timeout affects the new scheduling, basically failed allocation assignments, also `testCancellationOfIncompleteScheduling` ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java ########## @@ -244,104 +250,6 @@ public void testSendCancelAndReceiveFail() throws Exception { assertEquals(vertices.length - 1, exec.getVertex().getExecutionGraph().getRegisteredExecutions().size()); } - // -------------------------------------------------------------------------------------------- - // Actions after a vertex has been canceled or while canceling - // -------------------------------------------------------------------------------------------- - - @Test - public void testScheduleOrDeployAfterCancel() { - try { - final ExecutionVertex vertex = getExecutionVertex(); - setVertexState(vertex, ExecutionState.CANCELED); - - assertEquals(ExecutionState.CANCELED, vertex.getExecutionState()); - - // 1) - // scheduling after being canceled should be tolerated (no exception) because - // it can occur as the result of races - { - vertex.scheduleForExecution( - TestingSlotProviderStrategy.from(new ProgrammedSlotProvider(1)), - LocationPreferenceConstraint.ALL, - Collections.emptySet()); - - assertEquals(ExecutionState.CANCELED, vertex.getExecutionState()); - } - - // 2) - // deploying after canceling from CREATED needs to raise an exception, because - // the scheduler (or any caller) needs to know that the slot should be released - try { - - final LogicalSlot slot = new TestingLogicalSlotBuilder().createTestingLogicalSlot(); - - vertex.deployToSlot(slot); - fail("Method should throw an exception"); - } - catch (IllegalStateException e) { - assertEquals(ExecutionState.CANCELED, vertex.getExecutionState()); - } - } - catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void testActionsWhileCancelling() { Review comment: the test here look to me more like checking the valid state transitions. are the same tests not actual for the new scheduler (`scheduler.updateTaskExecutionState`)? ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexInputConstraintTest.java ########## @@ -1,276 +0,0 @@ -/* - * 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.executiongraph; - -import org.apache.flink.api.common.InputDependencyConstraint; -import org.apache.flink.api.common.JobStatus; -import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor; -import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter; -import org.apache.flink.runtime.execution.ExecutionState; -import org.apache.flink.runtime.executiongraph.utils.SimpleSlotProvider; -import org.apache.flink.runtime.io.network.partition.ResultPartitionID; -import org.apache.flink.runtime.io.network.partition.ResultPartitionType; -import org.apache.flink.runtime.jobgraph.DistributionPattern; -import org.apache.flink.runtime.jobgraph.JobGraph; -import org.apache.flink.runtime.jobgraph.JobVertex; -import org.apache.flink.runtime.jobgraph.JobVertexID; -import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable; -import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider; -import org.apache.flink.runtime.taskmanager.TaskExecutionState; -import org.apache.flink.util.TestLogger; - -import org.junit.Test; - -import java.time.Duration; -import java.util.Arrays; -import java.util.List; - -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.isInExecutionState; -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.waitForAllExecutionsPredicate; -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.waitUntilExecutionVertexState; -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.waitUntilJobStatus; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -/** - * Tests for the inputs constraint for {@link ExecutionVertex}. - */ -public class ExecutionVertexInputConstraintTest extends TestLogger { Review comment: is performance test not actual for the `InputDependencyConstraintChecker`? ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java ########## @@ -1,866 +0,0 @@ -/* - * 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.executiongraph; - -import org.apache.flink.api.common.ExecutionConfig; -import org.apache.flink.api.common.JobID; -import org.apache.flink.api.common.JobStatus; -import org.apache.flink.api.common.restartstrategy.RestartStrategies; -import org.apache.flink.api.common.time.Time; -import org.apache.flink.runtime.clusterframework.types.AllocationID; -import org.apache.flink.runtime.clusterframework.types.ResourceProfile; -import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor; -import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter; -import org.apache.flink.runtime.execution.ExecutionState; -import org.apache.flink.runtime.execution.SuppressRestartsException; -import org.apache.flink.runtime.executiongraph.failover.FailoverStrategy; -import org.apache.flink.runtime.executiongraph.restart.FixedDelayRestartStrategy; -import org.apache.flink.runtime.executiongraph.restart.InfiniteDelayRestartStrategy; -import org.apache.flink.runtime.executiongraph.restart.RestartStrategy; -import org.apache.flink.runtime.executiongraph.utils.NotCancelAckingTaskGateway; -import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway; -import org.apache.flink.runtime.executiongraph.utils.SimpleSlotProvider; -import org.apache.flink.runtime.io.network.partition.ResultPartitionType; -import org.apache.flink.runtime.jobgraph.DistributionPattern; -import org.apache.flink.runtime.jobgraph.JobGraph; -import org.apache.flink.runtime.jobgraph.JobVertex; -import org.apache.flink.runtime.jobgraph.ScheduleMode; -import org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup; -import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway; -import org.apache.flink.runtime.jobmaster.JobMasterId; -import org.apache.flink.runtime.jobmaster.slotpool.LocationPreferenceSlotSelectionStrategy; -import org.apache.flink.runtime.jobmaster.slotpool.Scheduler; -import org.apache.flink.runtime.jobmaster.slotpool.SchedulerImpl; -import org.apache.flink.runtime.jobmaster.slotpool.SlotPool; -import org.apache.flink.runtime.jobmaster.slotpool.SlotPoolImpl; -import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider; -import org.apache.flink.runtime.jobmaster.slotpool.TestingSlotPoolImpl; -import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway; -import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway; -import org.apache.flink.runtime.taskexecutor.slot.SlotOffer; -import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation; -import org.apache.flink.runtime.taskmanager.TaskManagerLocation; -import org.apache.flink.runtime.testtasks.NoOpInvokable; -import org.apache.flink.util.FlinkException; -import org.apache.flink.util.TestLogger; - -import org.junit.Test; - -import javax.annotation.Nonnull; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.function.Consumer; - -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.completeCancellingForAllVertices; -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.createNoOpVertex; -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.finishAllVertices; -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.switchToRunning; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.lessThanOrEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -/** - * Tests the restart behaviour of the {@link ExecutionGraph}. - */ -public class ExecutionGraphRestartTest extends TestLogger { Review comment: not sure the following tests are covered in new scheduler: ``` testCancelWhileFailing testFailWhileCanceling testTaskFailingWhileGlobalFailing testFailingExecutionAfterRestart testFailExecution(Graph)AfterCancel testSuspendWhileRestarting testFailureWhileRestarting ``` ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphNotEnoughResourceTest.java ########## @@ -113,29 +119,28 @@ public void testRestartWithSlotSharingAndNotEnoughResources() throws Exception { final JobGraph jobGraph = new JobGraph(TEST_JOB_ID, "Test Job", source, sink); jobGraph.setScheduleMode(ScheduleMode.EAGER); - TestRestartStrategy restartStrategy = new TestRestartStrategy(numRestarts, false); + RestartBackoffTimeStrategy restartStrategy = new FixedDelayRestartBackoffTimeStrategy.FixedDelayRestartBackoffTimeStrategyFactory(numRestarts, 0).create(); - final ExecutionGraph eg = TestingExecutionGraphBuilder - .newBuilder() - .setJobGraph(jobGraph) - .setSlotProvider(scheduler) - .setRestartStrategy(restartStrategy) - .setAllocationTimeout(Time.milliseconds(1L)) + final SchedulerBase schedulerNG = SchedulerTestingUtils + .newSchedulerBuilderWithDefaultSlotAllocator(jobGraph, scheduler, Time.milliseconds(1)) + .setRestartBackoffTimeStrategy(restartStrategy) + .setSchedulingStrategyFactory(new EagerSchedulingStrategy.Factory()) + .setFailoverStrategyFactory(new RestartAllFailoverStrategy.Factory()) .build(); + final ExecutionGraph eg = schedulerNG.getExecutionGraph(); Review comment: ok ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphVariousFailuesTest.java ########## @@ -20,86 +20,31 @@ import org.apache.flink.api.common.JobStatus; import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter; -import org.apache.flink.runtime.execution.SuppressRestartsException; -import org.apache.flink.runtime.executiongraph.restart.InfiniteDelayRestartStrategy; import org.apache.flink.runtime.io.network.partition.ResultPartitionID; import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.scheduler.SchedulerBase; +import org.apache.flink.runtime.scheduler.SchedulerTestingUtils; import org.apache.flink.util.TestLogger; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; - public class ExecutionGraphVariousFailuesTest extends TestLogger { - /** - * Test that failing in state restarting will retrigger the restarting logic. This means that - * it only goes into the state FAILED after the restart strategy says the job is no longer - * restartable. - */ - @Test - public void testFailureWhileRestarting() throws Exception { - final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(new InfiniteDelayRestartStrategy(2)); - eg.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); - eg.scheduleForExecution(); - - assertEquals(JobStatus.RUNNING, eg.getState()); - ExecutionGraphTestUtils.switchAllVerticesToRunning(eg); - - eg.failGlobal(new Exception("Test 1")); - assertEquals(JobStatus.FAILING, eg.getState()); - ExecutionGraphTestUtils.completeCancellingForAllVertices(eg); - - // we should restart since we have two restart attempts left - assertEquals(JobStatus.RESTARTING, eg.getState()); - - eg.failGlobal(new Exception("Test 2")); - - // we should restart since we have one restart attempts left - assertEquals(JobStatus.RESTARTING, eg.getState()); - - eg.failGlobal(new Exception("Test 3")); - - // after depleting all our restart attempts we should go into Failed - assertEquals(JobStatus.FAILED, eg.getState()); - } - - /** - * Tests that a {@link SuppressRestartsException} in state RESTARTING stops the restarting - * immediately and sets the execution graph's state to FAILED. - */ - @Test - public void testSuppressRestartFailureWhileRestarting() throws Exception { - final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(new InfiniteDelayRestartStrategy(10)); - eg.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); - eg.scheduleForExecution(); - - assertEquals(JobStatus.RUNNING, eg.getState()); - ExecutionGraphTestUtils.switchAllVerticesToRunning(eg); - - eg.failGlobal(new Exception("test")); - assertEquals(JobStatus.FAILING, eg.getState()); - - ExecutionGraphTestUtils.completeCancellingForAllVertices(eg); - assertEquals(JobStatus.RESTARTING, eg.getState()); - - // suppress a possible restart - eg.failGlobal(new SuppressRestartsException(new Exception("Test"))); - - assertEquals(JobStatus.FAILED, eg.getState()); - } - /** * Tests that a failing scheduleOrUpdateConsumers call with a non-existing execution attempt * id, will not fail the execution graph. */ @Test public void testFailingScheduleOrUpdateConsumers() throws Exception { - final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(new InfiniteDelayRestartStrategy(10)); - eg.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); - eg.scheduleForExecution(); + final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(new JobGraph()).build(); + scheduler.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); + scheduler.startScheduling(); + + final ExecutionGraph eg = scheduler.getExecutionGraph(); Review comment: I think I meant we could call `SchedulerBase::scheduleOrUpdateConsumers` to test. ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionTest.java ########## @@ -82,202 +82,12 @@ private final TestingComponentMainThreadExecutor testMainThreadUtil = EXECUTOR_RESOURCE.getComponentMainThreadTestExecutor(); - /** - * Tests that slots are released if we cannot assign the allocated resource to the - * Execution. - */ - @Test - public void testSlotReleaseOnFailedResourceAssignment() throws Exception { Review comment: I am not sure we test allocation cancelation with the new scheduler ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/GlobalModVersionTest.java ########## @@ -1,200 +0,0 @@ -/* - * 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.executiongraph; - -import org.apache.flink.api.common.JobID; -import org.apache.flink.api.common.JobStatus; -import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter; -import org.apache.flink.runtime.execution.ExecutionState; -import org.apache.flink.runtime.executiongraph.failover.FailoverStrategy; -import org.apache.flink.runtime.executiongraph.failover.FailoverStrategy.Factory; -import org.apache.flink.runtime.executiongraph.restart.InfiniteDelayRestartStrategy; -import org.apache.flink.runtime.executiongraph.utils.SimpleSlotProvider; -import org.apache.flink.runtime.jobgraph.JobGraph; -import org.apache.flink.runtime.jobgraph.JobVertex; -import org.apache.flink.runtime.testtasks.NoOpInvokable; -import org.apache.flink.util.TestLogger; - -import org.junit.Test; - -import java.util.Random; - -import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.waitUntilExecutionState; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class GlobalModVersionTest extends TestLogger { Review comment: I am not sure these tests are not relevant for the new scheduling, like concurrent global/local failure attempts ---------------------------------------------------------------- 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]
