@Test
  public void testBlockingChannelConnectionPool() throws Exception {
    Properties props = new Properties();
    props.put("connectionpool.max.connections.per.port.plain.text", "5");
    props.put("connectionpool.max.connections.per.port.ssl", "5");
    props.put("clustermap.cluster.name", "test");
    props.put("clustermap.datacenter.name", "dc1");
    props.put("clustermap.host.name", "localhost");
    ConnectionPool connectionPool =
        new BlockingChannelConnectionPool(new ConnectionPoolConfig(new VerifiableProperties(props)), sslConfig,
            plainTextClusterMapConfig, new MetricRegistry());
    connectionPool.start();

    CountDownLatch shouldRelease = new CountDownLatch(1);
    CountDownLatch releaseComplete = new CountDownLatch(10);
    AtomicReference<Exception> exception = new AtomicReference<Exception>();
    Map<String, CountDownLatch> channelCount = new HashMap<String, CountDownLatch>();
    channelCount.put("localhost" + 6667, new CountDownLatch(5));
    channelCount.put("localhost" + 6668, new CountDownLatch(5));
    channelCount.put("localhost" + 6669, new CountDownLatch(5));
    Map<String, Port> channelToPortMap = new HashMap<String, Port>();
    channelToPortMap.put("localhost" + 6667, new Port(6667, PortType.PLAINTEXT));
    channelToPortMap.put("localhost" + 6668, new Port(6668, PortType.PLAINTEXT));
    channelToPortMap.put("localhost" + 6669, new Port(6669, PortType.PLAINTEXT));
    for (int i = 0; i < 10; i++) {
      ConnectionPoolThread connectionPoolThread =
          new ConnectionPoolThread(channelCount, channelToPortMap, connectionPool, false, shouldRelease,
              releaseComplete, exception);
      Thread t = new Thread(connectionPoolThread);
      t.start();
    }
    for (String channelStr : channelCount.keySet()) {
      awaitCountdown(channelCount.get(channelStr), 1000, exception, "Timed out waiting for channel count to reach 5");
    }
    // reset
    for (String channelStr : channelCount.keySet()) {
      channelCount.put(channelStr, new CountDownLatch(5));
    }
    shouldRelease.countDown();
    for (String channelStr : channelCount.keySet()) {
      awaitCountdown(channelCount.get(channelStr), 1000, exception, "Timed out waiting for channel count to reach 5");
    }

    awaitCountdown(releaseComplete, 2000, exception, "Timed out while waiting for channels to be released");
    connectionPool.shutdown();
  }
Starts up an ambry server given a port number in localhost

@param port the port number over which ambry server needs to be started
@return the {@link SocketServer} referring to ambry's instance
@throws IOException
@throws InterruptedException
ambry-network/src/test/java/com/github/ambry/network/BlockingChannelConnectionPoolTest.java