public static void waitForChannelConnected(Selector selector, String node) throws IOException {
        int secondsLeft = 30;
        while (selector.channel(node) != null
                && !selector.channel(node).isConnected() && secondsLeft-- > 0) {
            selector.poll(1000L);
        }
        assertNotNull(selector.channel(node));
        assertTrue(selector.channel(node).isConnected(), String.format("Channel %s was not connected after 30 seconds", node));
    }
Common utility functions used by transport layer and authenticator tests.
clients/src/test/java/org/apache/kafka/common/network/NetworkTestUtils.java