@Test
  public void participantsWithNoMismatchTest() throws Exception {
    List<String> sealedReplicas = new ArrayList<>(Arrays.asList("10", "1", "4"));
    List<String> stoppedReplicas = new ArrayList<>();
    List<String> partiallySealedReplicas = new ArrayList<>();
    List<ClusterParticipant> participants = new ArrayList<>();
    // create a latch with init value = 2 to ensure both getSealedReplicas and getStoppedReplicas get called at least once
    CountDownLatch invocationLatch = new CountDownLatch(2);
    MockClusterParticipant participant1 =
        new MockClusterParticipant(sealedReplicas, partiallySealedReplicas, stoppedReplicas, invocationLatch, null,
            null);
    MockClusterParticipant participant2 =
        new MockClusterParticipant(sealedReplicas, partiallySealedReplicas, stoppedReplicas, null, null, null);
    participants.add(participant1);
    participants.add(participant2);
    clusterAgentsFactory.setClusterParticipants(participants);
    AmbryServer server =
        new AmbryServer(new VerifiableProperties(props), clusterAgentsFactory, notificationSystem, time);
    server.startup();
    assertTrue("The latch didn't count to zero within 5 secs", invocationLatch.await(5, TimeUnit.SECONDS));
    // verify that: 1. checker is instantiated 2.no mismatch event is emitted.
    assertNotNull("The mismatch metric should be created",
        server.getServerMetrics().sealedReplicasMismatchCount);
    assertNotNull("The partial seal mismatch metric should be created",
        server.getServerMetrics().partiallySealedReplicasMismatchCount);
    assertEquals("Sealed replicas mismatch count should be 0", 0,
        server.getServerMetrics().sealedReplicasMismatchCount.getCount());
    assertEquals("Partially sealed replicas mismatch count should be 0", 0,
        server.getServerMetrics().partiallySealedReplicasMismatchCount.getCount());
    assertEquals("Stopped replicas mismatch count should be 0", 0,
        server.getServerMetrics().stoppedReplicasMismatchCount.getCount());
    server.shutdown();
  }
Test that two participants are consistent in terms of sealed/stopped replicas.
@throws Exception
ambry-server/src/test/java/com/github/ambry/server/ParticipantsConsistencyTest.java