@Test
  public void allocateAndFreeSwapSegmentTest() throws Exception {
    requiredSwapSegmentsPerSize = 2;
    alloc = constructAllocator();
    alloc.initializePool(Collections.singletonList(new DiskSpaceRequirements(storeId0, 20, 3, 0)));
    verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 20, 3).addSwapSeg(20, 2));
    File f1 = allocateAndVerify(storeId0, "file1", 20, true);
    verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 20, 3).addSwapSeg(20, 1));
    freeAndVerify(storeId0, f1, 20, true);
    verifyPoolState(new ExpectedState().addStoreSeg(storeId0, 20, 3).addSwapSeg(20, 2));
  }
Test the case where swap segments are allocated and freed.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/DiskSpaceAllocatorTest.java