private void underSubscriptionTest(Properties props, String host, Port port, int underSubscriptionCount)
      throws Exception {
    AtomicReference<Exception> exception = new AtomicReference<Exception>();
    BlockingChannelInfo channelInfo =
        new BlockingChannelInfo(new ConnectionPoolConfig(new VerifiableProperties(props)), host, port,
            new MetricRegistry(), sslSocketFactory, sslConfig);
    CountDownLatch channelCount = new CountDownLatch(underSubscriptionCount);
    CountDownLatch shouldRelease = new CountDownLatch(1);
    CountDownLatch releaseComplete = new CountDownLatch(underSubscriptionCount);
    for (int i = 0; i < underSubscriptionCount; i++) {
      BlockingChannelInfoThread infoThread =
          new BlockingChannelInfoThread(channelInfo, channelCount, shouldRelease, releaseComplete, true, exception);
      Thread t = new Thread(infoThread);
      t.start();
    }
    shouldRelease.countDown();
    awaitCountdown(releaseComplete, 2000, exception, "Timed out while waiting for channels to be released");
    Assert.assertEquals(channelInfo.getNumberOfConnections(), underSubscriptionCount);
    channelInfo.getBlockingChannel(1000);
    Assert.assertEquals(channelInfo.getNumberOfConnections(), underSubscriptionCount);
    channelInfo.cleanup();
    Assert.assertEquals(channelInfo.getNumberOfConnections(), 0);
  }
Tests how connection failures are handled by BlockingChannelInfo.
ambry-network/src/test/java/com/github/ambry/network/BlockingChannelConnectionPoolTest.java