Guillaume Nodet created CAMEL-23889:
---------------------------------------

             Summary: Fix flaky camel-vertx-websocket surefire tests
                 Key: CAMEL-23889
                 URL: https://issues.apache.org/jira/browse/CAMEL-23889
             Project: Camel
          Issue Type: Bug
          Components: camel-vertx-websocket
            Reporter: Guillaume Nodet


The camel-vertx-websocket surefire tests fail intermittently on CI (both JDK 17 
and JDK 25). Three test issues were identified:

1. *VertxWebsocketConsumerAsClientReconnectTest*: Uses {{Thread.sleep(300)}} to 
wait for async Vert.x reconnection. The producer endpoint's cached WebSocket 
({{VertxWebsocketEndpoint.webSocket}}) may still appear open after server stop 
({{isClosed()}} returns false until the Vert.x event loop processes the TCP 
close frame), causing {{template.sendBody()}} to silently lose messages. 
Additionally, the "verify that we cannot send messages" assertion after 
{{stopRoute()}} is itself racy - the stale WebSocket may silently accept the 
send instead of throwing {{ConnectException}}.

2. *VertxWebsocketConsumerAsClientMaxReconnectTest*: Same {{Thread.sleep(300)}} 
and stale WebSocket race condition as above.

3. *VertxWebSocketEventTest*: Uses {{webSocketFuture.get(5000, 
TimeUnit.SECONDS)}} which is a 83-minute timeout (should be 5 seconds). This 
masks test failures by waiting far too long.

Fix: Replace {{Thread.sleep()}} with Awaitility-based async assertions. Wrap 
the "verify send fails" checks in {{await().untilAsserted()}} to handle the 
stale WebSocket race. Fix the timeout bug in EventTest.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to