Thesharing commented on a change in pull request #12917:
URL: https://github.com/apache/flink/pull/12917#discussion_r462776941
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolImplTest.java
##########
@@ -776,7 +686,9 @@ public void testOrphanedAllocationIsCanceledIfNotRemapped()
throws Exception {
final List<AllocationID> canceledAllocations = new
ArrayList<>();
resourceManagerGateway.setCancelSlotConsumer(canceledAllocations::add);
- try (SlotPoolImpl slotPool = createAndSetUpSlotPool()) {
+ try (SlotPoolImpl slotPool =
createAndSetUpSlotPool(resourceManagerGateway)) {
+
slotPool.registerTaskManager(taskManagerLocation.getResourceID());
Review comment:
Done.
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolTestBase.java
##########
@@ -0,0 +1,74 @@
+package org.apache.flink.runtime.jobmaster.slotpool;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.time.Time;
+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.jobmaster.SlotRequestId;
+import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
+import
org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
+import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Before;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Test base for {@link SlotPool} related test cases.
+ */
+public abstract class SlotPoolTestBase extends TestLogger {
+ protected static final Time TIMEOUT = Time.seconds(10L);
+
+ protected final ComponentMainThreadExecutor mainThreadExecutor =
+ ComponentMainThreadExecutorServiceAdapter.forMainThread();
+
+ protected TestingResourceManagerGateway resourceManagerGateway;
+ protected SlotPoolBuilder slotPoolBuilder;
+
+ @Before
+ public void setup() throws Exception {
+ resourceManagerGateway = new TestingResourceManagerGateway();
+ slotPoolBuilder = new
SlotPoolBuilder(mainThreadExecutor).setResourceManagerGateway(resourceManagerGateway);
+ }
+
+ protected TestingSlotPoolImpl createAndSetUpSlotPool() throws Exception
{
Review comment:
Got it. Done.
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolImplTest.java
##########
@@ -87,56 +77,38 @@
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* Tests for the {@link SlotPoolImpl}.
*/
-public class SlotPoolImplTest extends TestLogger {
-
- private final Time timeout = Time.seconds(10L);
-
- private JobID jobId;
+public class SlotPoolImplTest extends SlotPoolTestBase {
private TaskManagerLocation taskManagerLocation;
-
private SimpleAckingTaskManagerGateway taskManagerGateway;
- private TestingResourceManagerGateway resourceManagerGateway;
-
- private ComponentMainThreadExecutor mainThreadExecutor =
- ComponentMainThreadExecutorServiceAdapter.forMainThread();
-
@Before
- public void setUp() throws Exception {
- this.jobId = new JobID();
-
+ @Override
+ public void setup() throws Exception {
taskManagerLocation = new LocalTaskManagerLocation();
taskManagerGateway = new SimpleAckingTaskManagerGateway();
- resourceManagerGateway = new TestingResourceManagerGateway();
+ super.setup();
Review comment:
Agreed. Done.
----------------------------------------------------------------
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]