@Test
  public void diskStateUpdateTest() throws Exception {
    // create a HelixClusterManager with DynamicClusterChangeHandler
    Properties properties = new Properties();
    properties.putAll(props);
    ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(properties));
    HelixClusterManager helixClusterManager =
        new HelixClusterManager(clusterMapConfig, selfInstanceName, helixManagerFactory, new MetricRegistry());
    // disk capacity after initialization should equal to original value (100L * 1024 * 1024 * 1024)
    DiskId diskFromCluster = helixClusterManager.getAllPartitionIds(null).get(0).getReplicaIds().get(0).getDiskId();
    Disk disk = testHardwareLayout.getHardwareLayout()
        .findDisk(diskFromCluster.getDataNodeId().getHostname(), diskFromCluster.getDataNodeId().getPort(),
            diskFromCluster.getMountPath());
    assertNotNull(disk);
    assertEquals("Mismatch in disk state", HardwareState.AVAILABLE, diskFromCluster.getState());
    // update disk state
    disk.onHardDown();
    Utils.writeJsonObjectToFile(testHardwareLayout.getHardwareLayout().toJSONObject(), hardwareLayoutPath);
    helixCluster.upgradeWithNewHardwareLayout(hardwareLayoutPath);
    assertEquals("Mismatch in disk state", HardwareState.UNAVAILABLE, diskFromCluster.getState());
    helixClusterManager.close();
  }
Test the case where the disk state is updated dynamically.
@throws Exception
ambry-clustermap/src/test/java/com/github/ambry/clustermap/ClusterChangeHandlerTest.java