Fix timing issue in SslTransportLayerTest.testCloseSsl
Ensure that server-side channel is ready before it is muted in the test.
Reviewers: Ismael Juma
@@ -860,6 +860,11 @@ public class SslTransportLayerTest {
selector.connect(node, addr, BUFFER_SIZE, BUFFER_SIZE);
NetworkTestUtils.waitForChannelReady(selector, node);
+ // `waitForChannelReady` waits for client-side channel to be ready. This is sufficient for other tests
+ // operating on the client-side channel. But here, we are muting the server-side channel below, so we
+ // need to wait for the server-side channel to be ready as well.
+ TestUtils.waitForCondition(() -> server.selector().channels().stream().allMatch(KafkaChannel::ready),
+ "Channel not ready");
final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
server.outputChannel(Channels.newChannel(bytesOut));
