You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2019/05/27 12:16:30 UTC

[flink] branch master updated: [FLINK-12267][runtime] Port SimpleSlotTest to new code base

This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new be7f6db  [FLINK-12267][runtime] Port SimpleSlotTest to new code base
be7f6db is described below

commit be7f6db3c25bec9b1f611cd5bc50602782d9a000
Author: leesf <49...@qq.com>
AuthorDate: Mon May 27 20:16:14 2019 +0800

    [FLINK-12267][runtime] Port SimpleSlotTest to new code base
---
 .../flink/runtime/instance/SimpleSlotTest.java     | 33 +++++++++-------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/instance/SimpleSlotTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/instance/SimpleSlotTest.java
index 89fa90a..affe5cb 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/instance/SimpleSlotTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/instance/SimpleSlotTest.java
@@ -18,16 +18,15 @@
 
 package org.apache.flink.runtime.instance;
 
-import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
+import org.apache.flink.runtime.jobmanager.slots.TestingSlotOwner;
+import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.jobmaster.TestingPayload;
-import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
+import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
 import org.apache.flink.util.TestLogger;
 
 import org.junit.Test;
 
-import java.net.InetAddress;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -44,7 +43,7 @@ public class SimpleSlotTest extends  TestLogger {
 				SimpleSlot slot = getSlot();
 				assertTrue(slot.isAlive());
 
-				slot.releaseSlot();
+				slot.releaseSlot(null);
 				assertFalse(slot.isAlive());
 				assertTrue(slot.isCanceled());
 				assertTrue(slot.isReleased());
@@ -112,7 +111,7 @@ public class SimpleSlotTest extends  TestLogger {
 			// assign to released
 			{
 				SimpleSlot slot = getSlot();
-				slot.releaseSlot();
+				slot.releaseSlot(null);
 
 				assertFalse(slot.tryAssignPayload(payload1));
 				assertNull(slot.getPayload());
@@ -124,19 +123,13 @@ public class SimpleSlotTest extends  TestLogger {
 		}
 	}
 
-	public static SimpleSlot getSlot() throws Exception {
-		ResourceID resourceID = ResourceID.generate();
-		HardwareDescription hardwareDescription = new HardwareDescription(4, 2L*1024*1024*1024, 1024*1024*1024, 512*1024*1024);
-		InetAddress address = InetAddress.getByName("127.0.0.1");
-		TaskManagerLocation connection = new TaskManagerLocation(resourceID, address, 10001);
-
-		Instance instance = new Instance(
-			new SimpleAckingTaskManagerGateway(),
-			connection,
-			new InstanceID(),
-			hardwareDescription,
-			1);
-
-		return instance.allocateSimpleSlot();
+	public static SimpleSlot getSlot() {
+		final TestingSlotOwner slotOwner = new TestingSlotOwner();
+		slotOwner.setReturnAllocatedSlotConsumer((LogicalSlot logicalSlot) -> ((SimpleSlot) logicalSlot).markReleased());
+		return new SimpleSlot(
+			slotOwner,
+			new LocalTaskManagerLocation(),
+			0,
+			new SimpleAckingTaskManagerGateway());
 	}
 }