You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2021/07/14 14:55:19 UTC
[flink] 19/33: [FLINK-22477][tests] Remove AllocatedSlotsTest and
AvailableSlotsTest
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit a3bcef16b0ea473aa4ddef1e2620de61244a8959
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Tue Jul 13 16:53:58 2021 +0200
[FLINK-22477][tests] Remove AllocatedSlotsTest and AvailableSlotsTest
---
.../jobmaster/slotpool/AllocatedSlotsTest.java | 149 ---------------------
.../jobmaster/slotpool/AvailableSlotsTest.java | 90 -------------
2 files changed, 239 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotsTest.java
deleted file mode 100644
index fe7de53..0000000
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotsTest.java
+++ /dev/null
@@ -1,149 +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.jobmaster.slotpool;
-
-import org.apache.flink.runtime.clusterframework.types.AllocationID;
-import org.apache.flink.runtime.clusterframework.types.ResourceID;
-import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
-import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
-import org.apache.flink.runtime.jobmaster.SlotRequestId;
-import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
-import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
-import org.apache.flink.util.TestLogger;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-public class AllocatedSlotsTest extends TestLogger {
-
- @Test
- public void testOperations() throws Exception {
- SlotPoolImpl.AllocatedSlots allocatedSlots = new SlotPoolImpl.AllocatedSlots();
-
- final AllocationID allocation1 = new AllocationID();
- final SlotRequestId slotRequestID = new SlotRequestId();
- final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
- final ResourceID resource1 = taskManagerLocation.getResourceID();
- final AllocatedSlot slot1 = createSlot(allocation1, taskManagerLocation);
-
- allocatedSlots.add(slotRequestID, slot1);
-
- assertTrue(allocatedSlots.contains(slot1.getAllocationId()));
- assertTrue(allocatedSlots.containResource(resource1));
-
- assertEquals(slot1, allocatedSlots.get(allocation1));
- assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size());
- assertEquals(1, allocatedSlots.size());
-
- final AllocationID allocation2 = new AllocationID();
- final SlotRequestId slotRequestID2 = new SlotRequestId();
- final AllocatedSlot slot2 = createSlot(allocation2, taskManagerLocation);
-
- allocatedSlots.add(slotRequestID2, slot2);
-
- assertTrue(allocatedSlots.contains(slot1.getAllocationId()));
- assertTrue(allocatedSlots.contains(slot2.getAllocationId()));
- assertTrue(allocatedSlots.containResource(resource1));
-
- assertEquals(slot1, allocatedSlots.get(allocation1));
- assertEquals(slot2, allocatedSlots.get(allocation2));
- assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size());
- assertEquals(2, allocatedSlots.size());
-
- final AllocationID allocation3 = new AllocationID();
- final SlotRequestId slotRequestID3 = new SlotRequestId();
- final TaskManagerLocation taskManagerLocation2 = new LocalTaskManagerLocation();
- final ResourceID resource2 = taskManagerLocation2.getResourceID();
- final AllocatedSlot slot3 = createSlot(allocation3, taskManagerLocation2);
-
- allocatedSlots.add(slotRequestID3, slot3);
-
- assertTrue(allocatedSlots.contains(slot1.getAllocationId()));
- assertTrue(allocatedSlots.contains(slot2.getAllocationId()));
- assertTrue(allocatedSlots.contains(slot3.getAllocationId()));
- assertTrue(allocatedSlots.containResource(resource1));
- assertTrue(allocatedSlots.containResource(resource2));
-
- assertEquals(slot1, allocatedSlots.get(allocation1));
- assertEquals(slot2, allocatedSlots.get(allocation2));
- assertEquals(slot3, allocatedSlots.get(allocation3));
- assertEquals(2, allocatedSlots.getSlotsForTaskManager(resource1).size());
- assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size());
- assertEquals(3, allocatedSlots.size());
-
- allocatedSlots.remove(slot2.getAllocationId());
-
- assertTrue(allocatedSlots.contains(slot1.getAllocationId()));
- assertFalse(allocatedSlots.contains(slot2.getAllocationId()));
- assertTrue(allocatedSlots.contains(slot3.getAllocationId()));
- assertTrue(allocatedSlots.containResource(resource1));
- assertTrue(allocatedSlots.containResource(resource2));
-
- assertEquals(slot1, allocatedSlots.get(allocation1));
- assertNull(allocatedSlots.get(allocation2));
- assertEquals(slot3, allocatedSlots.get(allocation3));
- assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource1).size());
- assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size());
- assertEquals(2, allocatedSlots.size());
-
- allocatedSlots.remove(slot1.getAllocationId());
-
- assertFalse(allocatedSlots.contains(slot1.getAllocationId()));
- assertFalse(allocatedSlots.contains(slot2.getAllocationId()));
- assertTrue(allocatedSlots.contains(slot3.getAllocationId()));
- assertFalse(allocatedSlots.containResource(resource1));
- assertTrue(allocatedSlots.containResource(resource2));
-
- assertNull(allocatedSlots.get(allocation1));
- assertNull(allocatedSlots.get(allocation2));
- assertEquals(slot3, allocatedSlots.get(allocation3));
- assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size());
- assertEquals(1, allocatedSlots.getSlotsForTaskManager(resource2).size());
- assertEquals(1, allocatedSlots.size());
-
- allocatedSlots.remove(slot3.getAllocationId());
-
- assertFalse(allocatedSlots.contains(slot1.getAllocationId()));
- assertFalse(allocatedSlots.contains(slot2.getAllocationId()));
- assertFalse(allocatedSlots.contains(slot3.getAllocationId()));
- assertFalse(allocatedSlots.containResource(resource1));
- assertFalse(allocatedSlots.containResource(resource2));
-
- assertNull(allocatedSlots.get(allocation1));
- assertNull(allocatedSlots.get(allocation2));
- assertNull(allocatedSlots.get(allocation3));
- assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource1).size());
- assertEquals(0, allocatedSlots.getSlotsForTaskManager(resource2).size());
- assertEquals(0, allocatedSlots.size());
- }
-
- private AllocatedSlot createSlot(
- final AllocationID allocationId, final TaskManagerLocation taskManagerLocation) {
- return new AllocatedSlot(
- allocationId,
- taskManagerLocation,
- 0,
- ResourceProfile.ANY,
- new SimpleAckingTaskManagerGateway());
- }
-}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AvailableSlotsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AvailableSlotsTest.java
deleted file mode 100644
index b9a4e4f..0000000
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AvailableSlotsTest.java
+++ /dev/null
@@ -1,90 +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.jobmaster.slotpool;
-
-import org.apache.flink.runtime.clusterframework.types.AllocationID;
-import org.apache.flink.runtime.clusterframework.types.ResourceID;
-import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
-import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
-import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
-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.assertTrue;
-
-/** Tests for {@link SlotPoolImpl.AvailableSlots}. */
-public class AvailableSlotsTest extends TestLogger {
-
- static final ResourceProfile DEFAULT_TESTING_PROFILE = ResourceProfile.fromResources(1.0, 512);
-
- @Test
- public void testAddAndRemove() {
- SlotPoolImpl.AvailableSlots availableSlots = new SlotPoolImpl.AvailableSlots();
-
- final ResourceID resource1 = new ResourceID("resource1");
- final ResourceID resource2 = new ResourceID("resource2");
-
- final AllocatedSlot slot1 = createAllocatedSlot(resource1);
- final AllocatedSlot slot2 = createAllocatedSlot(resource1);
- final AllocatedSlot slot3 = createAllocatedSlot(resource2);
-
- availableSlots.add(slot1, 1L);
- availableSlots.add(slot2, 2L);
- availableSlots.add(slot3, 3L);
-
- assertEquals(3, availableSlots.size());
- assertTrue(availableSlots.contains(slot1.getAllocationId()));
- assertTrue(availableSlots.contains(slot2.getAllocationId()));
- assertTrue(availableSlots.contains(slot3.getAllocationId()));
- assertTrue(availableSlots.containsTaskManager(resource1));
- assertTrue(availableSlots.containsTaskManager(resource2));
-
- availableSlots.removeAllForTaskManager(resource1);
-
- assertEquals(1, availableSlots.size());
- assertFalse(availableSlots.contains(slot1.getAllocationId()));
- assertFalse(availableSlots.contains(slot2.getAllocationId()));
- assertTrue(availableSlots.contains(slot3.getAllocationId()));
- assertFalse(availableSlots.containsTaskManager(resource1));
- assertTrue(availableSlots.containsTaskManager(resource2));
-
- availableSlots.removeAllForTaskManager(resource2);
-
- assertEquals(0, availableSlots.size());
- assertFalse(availableSlots.contains(slot1.getAllocationId()));
- assertFalse(availableSlots.contains(slot2.getAllocationId()));
- assertFalse(availableSlots.contains(slot3.getAllocationId()));
- assertFalse(availableSlots.containsTaskManager(resource1));
- assertFalse(availableSlots.containsTaskManager(resource2));
- }
-
- private static AllocatedSlot createAllocatedSlot(final ResourceID resourceId) {
- return new AllocatedSlot(
- new AllocationID(),
- new TaskManagerLocation(resourceId, InetAddress.getLoopbackAddress(), 42),
- 0,
- DEFAULT_TESTING_PROFILE,
- new SimpleAckingTaskManagerGateway());
- }
-}