public static LlapAllocatorBuffer[] prepareCustomFragmentedAllocator(
      BuddyAllocator a, int[] sizes, int[] dealloc, boolean doIncRef) {
    LlapAllocatorBuffer[] initial = new LlapAllocatorBuffer[sizes.length];
    for (int i = 0; i < sizes.length; ++i) {
      initial[i] = allocate(a, 1, sizes[i], i + 1, doIncRef)[0];
    }
    for (int i = 0; i < dealloc.length; ++i) {
      a.deallocate(initial[dealloc[i]]);
      initial[dealloc[i]] = null;
    }
    LOG.info("Before: " + a.testDump());
    a.setOomLoggingForTest(true);
    return initial;
  }
This relies on allocations basically being sequential, no internal reordering. Rather,
the specific paths it takes do; all the scenarios should work regardless of allocation.
llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestBuddyAllocatorForceEvict.java