You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by fc...@apache.org on 2025/07/01 14:39:36 UTC
(flink) branch master updated: [hotfix][test] Move `SlotSharingSlotAllocatorTest#getSlots` into `TestingSlot`
This is an automated email from the ASF dual-hosted git repository.
fcsaky 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 749f5134fe6 [hotfix][test] Move `SlotSharingSlotAllocatorTest#getSlots` into `TestingSlot`
749f5134fe6 is described below
commit 749f5134fe62311562129e3c37a1758b7c657903
Author: Yuepeng Pan <pa...@apache.org>
AuthorDate: Tue Jul 1 22:39:28 2025 +0800
[hotfix][test] Move `SlotSharingSlotAllocatorTest#getSlots` into `TestingSlot`
---
.../runtime/scheduler/adaptive/AdaptiveSchedulerTestBase.java | 7 +------
.../adaptive/allocator/SlotSharingSlotAllocatorTest.java | 10 +---------
.../runtime/scheduler/adaptive/allocator/TestingSlot.java | 10 ++++++++++
3 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerTestBase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerTestBase.java
index 9f856d785a3..9681a38a3d9 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerTestBase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerTestBase.java
@@ -48,8 +48,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Supplier;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
import static org.apache.flink.core.testutils.FlinkAssertions.assertThatFuture;
import static org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.createNoOpVertex;
@@ -154,10 +152,7 @@ public class AdaptiveSchedulerTestBase {
() ->
TestingFreeSlotTracker.newBuilder()
.setGetFreeSlotsInformationSupplier(
- () ->
- IntStream.range(0, freeSlots)
- .mapToObj(v -> new TestingSlot())
- .collect(Collectors.toSet()))
+ () -> TestingSlot.getSlots(freeSlots))
.build())
.build();
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/SlotSharingSlotAllocatorTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/SlotSharingSlotAllocatorTest.java
index f6260f4fb7e..dc5800b1719 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/SlotSharingSlotAllocatorTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/SlotSharingSlotAllocatorTest.java
@@ -37,7 +37,6 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -47,6 +46,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.IntStream;
+import static org.apache.flink.runtime.scheduler.adaptive.allocator.TestingSlot.getSlots;
import static org.assertj.core.api.Assertions.assertThat;
/** Tests for the {@link SlotSharingSlotAllocator}. */
@@ -488,12 +488,4 @@ class SlotSharingSlotAllocatorTest {
assertThat(allocated.get(allocation1)).contains(vertex2.getJobVertexID());
assertThat(allocated.get(allocation2)).contains(vertex3.getJobVertexID());
}
-
- private static Collection<SlotInfo> getSlots(int count) {
- final Collection<SlotInfo> slotInfo = new ArrayList<>();
- for (int i = 0; i < count; i++) {
- slotInfo.add(new TestingSlot());
- }
- return slotInfo;
- }
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/TestingSlot.java b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/TestingSlot.java
index 0976ac4881e..c44a1e0c2ac 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/TestingSlot.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/allocator/TestingSlot.java
@@ -24,6 +24,10 @@ import org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlot;
import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
+import java.util.Collection;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
/** An implementation of {@link PhysicalSlot}for testing. */
public class TestingSlot implements PhysicalSlot {
@@ -94,4 +98,10 @@ public class TestingSlot implements PhysicalSlot {
public boolean tryAssignPayload(Payload payload) {
throw new UnsupportedOperationException();
}
+
+ public static Collection<PhysicalSlot> getSlots(int count) {
+ return IntStream.range(0, count)
+ .mapToObj(v -> new TestingSlot())
+ .collect(Collectors.toList());
+ }
}