@Test
  public void testNonDefaultCompaction() {
    DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
    diskRegionProperties.setRegionName(regionName);
    diskRegionProperties.setRolling(false);
    diskRegionProperties.setDiskDirs(diskDirs);
    diskRegionProperties.setAllowForceCompaction(true);
    diskRegionProperties.setPersistBackup(true);
    diskRegionProperties.setCompactionThreshold(90);

    DiskStoreFactory diskStoreFactory = toDiskStoreFactory(diskRegionProperties);

    createDiskStoreWithSizeInBytes(diskStoreName, diskStoreFactory);

    Region<String, String> region =
        createRegion(regionName, diskStoreName, true, true, false, false, 0);

    region.put("key1", "value1");
    region.put("key2", "value2");

    // Only remove 1 of the entries. This wouldn't trigger compaction with the default threshold,
    // since there are two entries.
    region.remove("key1");

    // the following forceCompaction should go ahead and do a roll and compact it
    Oplog oplog = getDiskRegion(region).testHook_getChild();
    boolean compacted = getDiskStore(region).forceCompaction();

    assertThat(oplog.testConfirmCompacted()).isTrue();
    assertThat(compacted).isTrue();
  }
Confirm that forceCompaction waits for the compaction to finish
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionJUnitTest.java