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

rjung 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 e778178657 Improve websocket junit test timing behavior.
e778178657 is described below

commit e778178657c763df02f9f2475a53bdbd1df7d47c
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 a720dcd6ca..d8d5d672cb 100644
--- a/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
+++ b/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
@@ -58,6 +58,9 @@ public class TestWebSocketFrameClientSSL extends 
WebSocketBaseTest {
         
clientEndpointConfig.getUserProperties().put(Constants.SSL_TRUSTSTORE_PROPERTY, 
TesterSupport.CA_JKS);
         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);
@@ -130,6 +133,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 ba41b82383..8d414fe33d 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 3a2afad1df..5460d4fc78 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 7af3bcc12a..1f35ec0be3 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