Skip to content

Commit

Permalink
[FLINK-18355][tests] Remove redundant codes in SlotPoolImplTest#testA…
Browse files Browse the repository at this point in the history
…llocateWithFreeSlot
  • Loading branch information
Thesharing authored and zhuzhurk committed Aug 13, 2020
1 parent 3636695 commit 8cf4dde
Showing 1 changed file with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,39 +208,23 @@ public void testAllocateWithFreeSlot() throws Exception {
try (SlotPoolImpl slotPool = createAndSetUpSlotPool()) {
slotPool.registerTaskManager(taskManagerLocation.getResourceID());

final SlotRequestId requestId1 = new SlotRequestId();
final CompletableFuture<PhysicalSlot> future1 = requestNewAllocatedSlot(
slotPool,
requestId1
);
assertFalse(future1.isDone());

final SlotRequest slotRequest = slotRequestFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);

final AllocationID allocationId = new AllocationID();
final SlotOffer slotOffer = new SlotOffer(
slotRequest.getAllocationId(),
allocationId,
0,
DEFAULT_TESTING_PROFILE);

assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));

final PhysicalSlot slot1 = future1.get(1, TimeUnit.SECONDS);
assertTrue(future1.isDone());

// return this slot to pool
slotPool.releaseSlot(requestId1, null);

assertEquals(1, slotPool.getAvailableSlots().size());
assertEquals(0, slotPool.getAllocatedSlots().size());

final Optional<PhysicalSlot> physicalSlot = slotPool.allocateAvailableSlot(
Optional<PhysicalSlot> physicalSlot = slotPool.allocateAvailableSlot(
new SlotRequestId(),
slotRequest.getAllocationId());
allocationId);

// second allocation fulfilled by previous slot returning
assertTrue(physicalSlot.isPresent());
final PhysicalSlot slot2 = physicalSlot.get();
assertEquals(slot1, slot2);
assertEquals(0, slotPool.getAvailableSlots().size());
assertEquals(1, slotPool.getAllocatedSlots().size());
}
}

Expand Down

0 comments on commit 8cf4dde

Please sign in to comment.