public void runComplexTests(boolean isBruteOnly) {
    runCustomDiscard(create(1024, 1, 1024, false, isBruteOnly),
        new int[] { 256, 128, 64, 64, 256, 64, 64, 128 },
        new int[] { 0,            3,            6, 7 }, 512 );
    runCustomDiscard(create(1024, 1, 1024, false, isBruteOnly),
        new int[] { 256, 64, 64, 64, 64, 256, 64, 64, 128 },
        new int[] { 0,                4,           7, 8 }, 512 );

    runCustomDiscard(create(512, 2, 1024, false, isBruteOnly),
        new int[] { 256, 128, 64, 64, 256, 64, 64, 128 },
        new int[] { 0,            3,            6, 7 }, 512 );
    runCustomDiscard(create(512, 2, 1024, false, isBruteOnly),
        new int[] { 256, 64, 64, 64, 64, 256, 64, 64, 128 },
        new int[] { 0,                4,           7, 8 }, 512 );
  }
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