@Test
  public void testDistributedLock() throws Exception {
    ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props));
    MetricRegistry metricRegistry = new MetricRegistry();
    HelixParticipant helixParticipant =
        new HelixParticipant(mock(HelixClusterManager.class), clusterMapConfig, new HelixFactory(), metricRegistry,
            getDefaultZkConnectStr(clusterMapConfig), true);

    // By default, helix library would use shared zookeeper connection
    DistributedLock lock1 = helixParticipant.getDistributedLock("TestDistributedLock", "for testing");
    DistributedLock lock2 = helixParticipant.getDistributedLock("TestDistributedLock", "for testing");
    testTwoDistributedLocks(lock1, lock2);
    helixParticipant.close();
  }
Test distributed lock with same zookeeper connection
@throws Exception
ambry-clustermap/src/test/java/com/github/ambry/clustermap/HelixParticipantTest.java