@Test
  public void testEnableDisable() {
    // without compaction enabled.
    compactionManager.enable();
    // functions should work ok
    assertNull("Compaction thread should not be created",
        TestUtils.getThreadByThisName(CompactionManager.THREAD_NAME_PREFIX));
    assertFalse("Compaction Executor should not be running", compactionManager.isCompactionExecutorRunning());
    assertFalse("Compactions should not be scheduled after termination",
        compactionManager.scheduleNextForCompaction(blobStore));
    compactionManager.disable();
    compactionManager.awaitTermination();

    // with compaction enabled.
    properties.setProperty("store.compaction.triggers", ALL_COMPACTION_TRIGGERS);
    config = new StoreConfig(new VerifiableProperties(properties));
    StorageManagerMetrics metrics = new StorageManagerMetrics(new MetricRegistry());
    compactionManager = new CompactionManager(MOUNT_PATH, config, Collections.singleton(blobStore), metrics, time);
    compactionManager.enable();
    assertNotNull("Compaction thread should be created",
        TestUtils.getThreadByThisName(CompactionManager.THREAD_NAME_PREFIX));
    compactionManager.disable();
    compactionManager.awaitTermination();
    assertFalse("Compaction thread should not be running", compactionManager.isCompactionExecutorRunning());
    assertFalse("Compactions should not be scheduled after termination",
        compactionManager.scheduleNextForCompaction(blobStore));
  }
Tests the enabling and disabling of the {@link CompactionManager} with and without compaction enabled.
ambry-store/src/test/java/com/github/ambry/store/CompactionManagerTest.java