private void assertStateEquivalency(Set<String> expectedDownInstances, Set<String> expectedUpInstances) {
    Set<String> upInstancesInClusterManager = new HashSet<>();
    Set<String> downInstancesInClusterManager = new HashSet<>();
    for (DataNodeId dataNode : clusterManager.getDataNodeIds()) {
      if (dataNode.getState() == HardwareState.UNAVAILABLE) {
        assertTrue("Datanode should not be a duplicate", downInstancesInClusterManager.add(
            ClusterMapUtils.getInstanceName(dataNode.getHostname(), dataNode.getPort())));
      } else {
        assertTrue("Datanode should not be a duplicate", upInstancesInClusterManager.add(
            ClusterMapUtils.getInstanceName(dataNode.getHostname(), dataNode.getPort())));
      }
    }
    assertEquals(expectedDownInstances, downInstancesInClusterManager);
    assertEquals(expectedUpInstances, upInstancesInClusterManager);
    Pair<Set<String>, Set<String>> writablePartitionsInTwoPlaces = getWritablePartitions();
    assertEquals(writablePartitionsInTwoPlaces.getFirst(), writablePartitionsInTwoPlaces.getSecond());
    testAllPartitions();
  }
Assert that the state of datanodes in the cluster manager's view are consistent with their actual states in the
cluster.
@param expectedDownInstances the expected down instances set in cluster manager.
@param expectedUpInstances the expected up instances set in cluster manager.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/HelixClusterManagerTest.java