GJL commented on a change in pull request #8486: [FLINK-12372] [runtime] implement ExecutionSlotAllocator URL: https://github.com/apache/flink/pull/8486#discussion_r292337814
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/PreferredLocationsCalculationTest.java ########## @@ -0,0 +1,109 @@ +/* + * 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.runtime.jobgraph.JobVertexID; +import org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID; +import org.apache.flink.runtime.taskmanager.TaskManagerLocation; +import org.apache.flink.util.TestLogger; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasSize; +import static org.junit.Assert.assertThat; + +/** + * Tests for the calculation of preferred locations based on inputs in {@link DefaultExecutionSlotAllocator}. + */ +public class PreferredLocationsCalculationTest extends TestLogger { + + /** + * Tests that the input edge will be ignored if it has too many different locations. + */ + @Test + public void testIgnoreEdgeOfTooManyLocations() { + final ExecutionVertexID consumerId = new ExecutionVertexID(new JobVertexID(), 0); + + TestingInputsLocationsRetriever.Builder locationRetrieverBuilder = new TestingInputsLocationsRetriever.Builder(); + JobVertexID jobVertexID = new JobVertexID(); + for (int i = 0; i < 9; i++) { + final ExecutionVertexID producerId = new ExecutionVertexID(jobVertexID, i); + locationRetrieverBuilder.connectConsumerToProducer(consumerId, producerId); + } + + final TestingInputsLocationsRetriever inputsLocationsRetriever = locationRetrieverBuilder.build(); + + CompletableFuture<Collection<TaskManagerLocation>> preferredLocations = + DefaultExecutionSlotAllocator.getPreferredLocationsBasedOnInputs(consumerId, inputsLocationsRetriever); + + assertThat(preferredLocations.getNow(null), hasSize(0)); Review comment: I think `.get()` is also applicable here. ---------------------------------------------------------------- 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
