This is an automated email from the ASF dual-hosted git repository.

rjung pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c8c87eba5 Improve websocket junit test timing behavior.
9c8c87eba5 is described below

commit 9c8c87eba5001bb6e220fabf68a6b9edae03ee91
Author: Rainer Jung <rainer.j...@kippdata.de>
AuthorDate: Thu Apr 18 13:28:21 2024 +0200

    Improve websocket junit test timing behavior.
    
    Since 11.0.0-M17 soome tests hit the default session close timeout
    of 30 seconds at the end of test.
    
    Set a session close timeout of 2 seconds for these tests instead.
---
 test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java   | 6 ++++++
 .../tomcat/websocket/TestWsWebSocketContainerTimeoutServer.java     | 3 +++
 test/org/apache/tomcat/websocket/server/TestSlowClient.java         | 3 +++
 .../websocket/server/TestWsRemoteEndpointImplServerDeadlock.java    | 3 +++
 4 files changed, 15 insertions(+)

diff --git a/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java 
b/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
index b8b661bed7..5abcb73a2a 100644
--- a/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
+++ b/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
@@ -105,6 +105,9 @@ public class TestWebSocketFrameClientSSL extends 
WebSocketBaseTest {
 
         Session wsSession = 
wsContainer.connectToServer(TesterProgrammaticEndpoint.class, 
clientEndpointConfig,
                 new URI("wss://localhost:" + getPort() + 
TesterFirehoseServer.PATH));
+        // Set a short session close timeout (milliseconds)
+        wsSession.getUserProperties().put(
+            
org.apache.tomcat.websocket.Constants.SESSION_CLOSE_TIMEOUT_PROPERTY, 
Long.valueOf(2000));
         CountDownLatch latch = new 
CountDownLatch(TesterFirehoseServer.MESSAGE_COUNT);
         BasicText handler = new BasicText(latch);
         wsSession.addMessageHandler(handler);
@@ -188,6 +191,9 @@ public class TestWebSocketFrameClientSSL extends 
WebSocketBaseTest {
             Assert.fail("There are [" + openConnectionCount + "] connections 
still open");
         }
 
+        // Set a short session close timeout (milliseconds)
+        wsSession.getUserProperties().put(
+            
org.apache.tomcat.websocket.Constants.SESSION_CLOSE_TIMEOUT_PROPERTY, 
Long.valueOf(2000));
         // Close the client session.
         wsSession.close();
     }
diff --git 
a/test/org/apache/tomcat/websocket/TestWsWebSocketContainerTimeoutServer.java 
b/test/org/apache/tomcat/websocket/TestWsWebSocketContainerTimeoutServer.java
index b3b31b699c..613fadde8c 100644
--- 
a/test/org/apache/tomcat/websocket/TestWsWebSocketContainerTimeoutServer.java
+++ 
b/test/org/apache/tomcat/websocket/TestWsWebSocketContainerTimeoutServer.java
@@ -100,6 +100,9 @@ public class TestWsWebSocketContainerTimeoutServer extends 
WsWebSocketContainerB
             loops++;
         }
 
+        // Set a short session close timeout (milliseconds)
+        wsSession.getUserProperties().put(
+            
org.apache.tomcat.websocket.Constants.SESSION_CLOSE_TIMEOUT_PROPERTY, 
Long.valueOf(2000));
         // Close the client session, primarily to allow the
         // BackgroundProcessManager to shut down.
         wsSession.close();
diff --git a/test/org/apache/tomcat/websocket/server/TestSlowClient.java 
b/test/org/apache/tomcat/websocket/server/TestSlowClient.java
index 411c395045..a9203609f5 100644
--- a/test/org/apache/tomcat/websocket/server/TestSlowClient.java
+++ b/test/org/apache/tomcat/websocket/server/TestSlowClient.java
@@ -70,6 +70,9 @@ public class TestSlowClient extends WebSocketBaseTest {
             count++;
         }
         Assert.assertTrue(wsSession.isOpen());
+        // Set a short session close timeout (milliseconds)
+        wsSession.getUserProperties().put(
+            
org.apache.tomcat.websocket.Constants.SESSION_CLOSE_TIMEOUT_PROPERTY, 
Long.valueOf(2000));
         wsSession.close();
 
         // BZ 64848 (non-container thread variant)
diff --git 
a/test/org/apache/tomcat/websocket/server/TestWsRemoteEndpointImplServerDeadlock.java
 
b/test/org/apache/tomcat/websocket/server/TestWsRemoteEndpointImplServerDeadlock.java
index 7959daa38c..86adf1ac1d 100644
--- 
a/test/org/apache/tomcat/websocket/server/TestWsRemoteEndpointImplServerDeadlock.java
+++ 
b/test/org/apache/tomcat/websocket/server/TestWsRemoteEndpointImplServerDeadlock.java
@@ -124,6 +124,9 @@ public class TestWsRemoteEndpointImplServerDeadlock extends 
WebSocketBaseTest {
         // Server buffers are full. Server cannot send any more messages.
         // Server is now blocked waiting for the client to read the messages.
 
+        // Set a short session close timeout (milliseconds)
+        session.getUserProperties().put(
+            
org.apache.tomcat.websocket.Constants.SESSION_CLOSE_TIMEOUT_PROPERTY, 
Long.valueOf(2000));
         // Close the session from the client
         session.close();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to