fvaleri commented on code in PR #12159:
URL: https://github.com/apache/kafka/pull/12159#discussion_r890306188


##########
clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java:
##########
@@ -603,23 +603,18 @@ private void verifyChannelExpiry(KafkaChannel channel) 
throws Exception {
     public void testCloseOldestConnectionWithMultiplePendingReceives() throws 
Exception {
         int expectedReceives = 5;
         KafkaChannel channel = 
createConnectionWithPendingReceives(expectedReceives);
-        String id = channel.id();
-        int completedReceives = 0;
+        int completedReceives = selector.completedReceives().size();
+
         while (selector.disconnected().isEmpty()) {
-            time.sleep(6000); // The max idle time is 5000ms
-            selector.poll(completedReceives == expectedReceives ? 0 : 1000);
+            time.sleep(CONNECTION_MAX_IDLE_MS + 1_000);
+            selector.poll(completedReceives == expectedReceives ? 0 : 1_000);
             completedReceives += selector.completedReceives().size();
-            if (!selector.completedReceives().isEmpty()) {
-                assertEquals(1, selector.completedReceives().size());
-                assertNotNull(selector.channel(id), "Channel should not have 
been expired");
-                assertTrue(selector.closingChannel(id) != null || 
selector.channel(id) != null, "Channel not found");
-                assertFalse(selector.disconnected().containsKey(id), 
"Disconnect notified too early");
-            }

Review Comment:
   Hi @ijuma, thanks for looking into this.
   
   You are right, I think the only missing assertion is the following.
   
   ```
   assertFalse(selector.disconnected().containsKey(id), "Disconnect notified 
too early");
   ```
   
   If disconnected() is not empty (i.e. the client closed the connection), then 
we would exit the while loop prematurely and the first assertion would fail. 
   
   I can add it back with a new PR if you think it's important.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to