This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 70a2e2b37b Refactor test to make it more robust.
70a2e2b37b is described below
commit 70a2e2b37bd2697f2437d5da624bddad6653ec04
Author: Mark Thomas <[email protected]>
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 b45f0b4698..6db82e565c 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: [email protected]
For additional commands, e-mail: [email protected]