This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 44056e43f8 Refactor test to make it more robust. 44056e43f8 is described below commit 44056e43f8d4c3e41a58ae46a3f1e9ea6ca3b8f4 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Feb 4 11:13:05 2025 +0000 Refactor test to make it more robust. The test was failing for NIO2 after changes to TesterFirehoseServer.SEND_TIME_OUT_MILLIS. This fixes that failure and makes the test more robust for any future changes. --- .../tomcat/websocket/server/TestSlowClient.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/org/apache/tomcat/websocket/server/TestSlowClient.java b/test/org/apache/tomcat/websocket/server/TestSlowClient.java index aa31657218..7f65243c1d 100644 --- a/test/org/apache/tomcat/websocket/server/TestSlowClient.java +++ b/test/org/apache/tomcat/websocket/server/TestSlowClient.java @@ -64,17 +64,24 @@ public class TestSlowClient extends WebSocketBaseTest { // Trigger the sending of the messages from the server wsSession.getBasicRemote().sendText("start"); - // Wait for server to close connection (it shouldn't) - // 20s should be long enough even for the slowest CI system. May need to - // extend this if not. + /* + * Wait for server to experience a write timeout. This should take TesterFirehoseServer.SEND_TIME_OUT_MILLIS + * plus however long it takes for the network buffer to fill up which should be a few milliseconds. An + * additional 10s should be enough even for the slowest CI system. + * + * As soon as the server has experienced the write timeout, send the session close message from the client and + * close the network connection. + */ + Thread.sleep(TesterFirehoseServer.SEND_TIME_OUT_MILLIS); int count = 0; - while (wsSession.isOpen() && count < 200) { - Thread.sleep(100); + while (wsSession.isOpen() && TesterFirehoseServer.Endpoint.getErrorCount() == 0 && count < 200) { + Thread.sleep(50); count++; } + Assert.assertTrue(TesterFirehoseServer.Endpoint.getErrorCount() > 0); Assert.assertTrue(wsSession.isOpen()); - // Cast so we can force the session to be closed quickly. + // Cast so we can force the session and the socket to be closed quickly. CloseReason cr = new CloseReason(CloseCodes.CLOSED_ABNORMALLY, ""); ((WsSession) wsSession).doClose(cr, cr, true); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org