Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the test cases with SlotPoolTestBase
- Loading branch information
1 parent
3e263c1
commit 3a52893
Showing
5 changed files
with
67 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...k-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolTestBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.apache.flink.runtime.jobmaster.slotpool; | ||
|
||
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.utils.TestingResourceManagerGateway; | ||
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 void requestNewAllocatedSlots(final SlotPool slotPool, final SlotRequestId... slotRequestIds) { | ||
for (SlotRequestId slotRequestId : slotRequestIds) { | ||
requestNewAllocatedSlot(slotPool, slotRequestId); | ||
} | ||
} | ||
|
||
protected CompletableFuture<PhysicalSlot> requestNewAllocatedSlot( | ||
final SlotPool slotPool, | ||
final SlotRequestId slotRequestId) { | ||
return requestNewAllocatedSlot(slotPool, slotRequestId, TIMEOUT); | ||
} | ||
|
||
protected CompletableFuture<PhysicalSlot> requestNewAllocatedSlot( | ||
final SlotPool slotPool, | ||
final SlotRequestId slotRequestId, | ||
final Time timeout) { | ||
return slotPool.requestNewAllocatedSlot(slotRequestId, ResourceProfile.UNKNOWN, timeout); | ||
} | ||
} |