private static void runCustomDiscard(BuddyAllocator a, int[] sizes, int[] dealloc, int size) {
    LlapAllocatorBuffer[] initial = prepareCustomFragmentedAllocator(a, sizes, dealloc, true);
    LlapAllocatorBuffer after = allocate(a, 1, size, initial.length + 1)[0];
    LOG.info("After: " + a.testDump());
    for (int i = 0; i < initial.length; ++i) {
      if (initial[i] == null) continue;
      checkTestValue(initial[i], i + 1, null, false);
      a.deallocate(initial[i]);
    }
    checkTestValue(after, initial.length + 1, null, true);
    a.deallocate(after);
  }
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