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 2019/02/13 09:17:19 UTC

[GitHub] tillrohrmann commented on a change in pull request #7690: [FLINK-11587][tests] Port CoLocationConstraintITCase to new code base

tillrohrmann commented on a change in pull request #7690: [FLINK-11587][tests] Port CoLocationConstraintITCase to new code base
URL: https://github.com/apache/flink/pull/7690#discussion_r256304674
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobExecutionITCase.java
 ##########
 @@ -0,0 +1,144 @@
+/*
+ * 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.jobmaster;
+
+import org.apache.flink.runtime.execution.Environment;
+import org.apache.flink.runtime.io.network.api.reader.RecordReader;
+import org.apache.flink.runtime.io.network.api.writer.RecordWriter;
+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.tasks.AbstractInvokable;
+import org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup;
+import org.apache.flink.runtime.minicluster.MiniCluster;
+import org.apache.flink.runtime.testutils.MiniClusterResource;
+import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
+import org.apache.flink.types.IntValue;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.util.concurrent.CompletableFuture;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Integration tests for job scheduling.
+ */
+public class JobExecutionITCase extends TestLogger {
+
+	private static final int SLOTS_PER_TM = 11;
+	private static final int NUM_TMS = 2;
+	private static final int PARALLELISM = SLOTS_PER_TM * NUM_TMS;
+
+	@ClassRule
+	public static final MiniClusterResource MINI_CLUSTER_RESOURCE = new MiniClusterResource(
+		new MiniClusterResourceConfiguration.Builder()
+			.setNumberSlotsPerTaskManager(SLOTS_PER_TM)
+			.setNumberTaskManagers(NUM_TMS)
+			.build());
+
+	@Test
+	public void testCoLocationConstraintJobExecution() throws Exception {
+		final JobGraph jobGraph = createJobGraph(PARALLELISM);
+
+		final MiniCluster miniCluster = MINI_CLUSTER_RESOURCE.getMiniCluster();
+
+		miniCluster.submitJob(jobGraph).get();
+
+		final CompletableFuture<JobResult> jobResultFuture = miniCluster.requestJobResult(jobGraph.getJobID());
+
+		assertThat(jobResultFuture.get().isSuccess(), is(true));
+	}
+
+	private JobGraph createJobGraph(int parallelism) {
+		final JobVertex sender = new JobVertex("Sender");
+		sender.setParallelism(parallelism);
+		sender.setInvokableClass(Sender.class);
+
+		final JobVertex receiver = new JobVertex("Receiver");
+		receiver.setParallelism(parallelism);
+		receiver.setInvokableClass(Receiver.class);
+
+		final SlotSharingGroup slotSharingGroup = new SlotSharingGroup();
+		receiver.setSlotSharingGroup(slotSharingGroup);
+		sender.setSlotSharingGroup(slotSharingGroup);
+
+		receiver.setStrictlyCoLocatedWith(sender);
 
 Review comment:
   this is true. We don't have true assertions making sure that task are being co-located. The `CountDownLatch` would enforce that both tasks are online at the same time. I think this is not what we want to guarantee here. Instead we should test that the tasks are deployed in the same slot and, thus, using local channels for communication. Maybe a non serializable record could do the trick here. I'll try it out.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services