From eeb5fe2b7f0c1cdf634a275f70f7e389397c8318 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Tue, 22 Sep 2026 21:00:37 -0400 Subject: [PATCH] test(apigatewayv2): drop the sleeps that guard nothing in the WebSocket lifecycle test (#4142) Seven sleeps between 0.5 and 2 seconds sat after sendClose().join(), none of them before an assertion: two ended their test, one preceded a reconnect that opens an independent connection, and the rest were trailing. Removing them takes about 8 seconds off the class without changing what it proves. --- .../apigatewayv2/WebSocketConnectionLifecycleTest.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/WebSocketConnectionLifecycleTest.java b/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/WebSocketConnectionLifecycleTest.java index 7cc4d35401..302835632b 100644 --- a/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/WebSocketConnectionLifecycleTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/WebSocketConnectionLifecycleTest.java @@ -236,7 +236,6 @@ class WebSocketConnectionLifecycleTest { WebSocket ws = connectWebSocket(wsApiId, "test"); assertNotNull(ws, "WebSocket connection should succeed when no $connect route is defined"); ws.sendClose(WebSocket.NORMAL_CLOSURE, "done").join(); - Thread.sleep(500); } // ──────────────────────────── Test 2: Connect with $connect route Lambda allow ──────────────────────────── @@ -259,7 +258,6 @@ class WebSocketConnectionLifecycleTest { WebSocket ws = connectWebSocket(wsApiId, "test"); assertNotNull(ws, "WebSocket connection should succeed when $connect Lambda returns 200"); ws.sendClose(WebSocket.NORMAL_CLOSURE, "done").join(); - Thread.sleep(500); } // ──────────────────────────── Test 3: Connect with $connect route Lambda deny ──────────────────────────── @@ -331,8 +329,6 @@ class WebSocketConnectionLifecycleTest { WebSocket ws = connectWebSocket(wsApiId, "test"); assertNotNull(ws); ws.sendClose(WebSocket.NORMAL_CLOSURE, "done").join(); - // Give time for the $disconnect handler to execute - Thread.sleep(2000); } // ──────────────────────────── Test 6: Disconnect cleans up connection ──────────────────────────── @@ -344,14 +340,11 @@ class WebSocketConnectionLifecycleTest { WebSocket ws = connectWebSocket(wsApiId, "test"); assertNotNull(ws); ws.sendClose(WebSocket.NORMAL_CLOSURE, "done").join(); - // Give time for cleanup - Thread.sleep(2000); // Attempting to reconnect should work (proving old connection was cleaned up) WebSocket ws2 = connectWebSocket(wsApiId, "test"); assertNotNull(ws2); ws2.sendClose(WebSocket.NORMAL_CLOSURE, "done").join(); - Thread.sleep(500); } // ──────────────────────────── Test 7: Disconnect error does not propagate to client ──────────────────────────── @@ -376,8 +369,6 @@ class WebSocketConnectionLifecycleTest { // The close should complete normally ws.sendClose(WebSocket.NORMAL_CLOSURE, "done").join(); - // Give time for the $disconnect handler to execute (and fail) - Thread.sleep(2000); // If we got here without exception, the error was not propagated } @@ -441,7 +432,6 @@ class WebSocketConnectionLifecycleTest { for (WebSocket ws : connections) { ws.sendClose(WebSocket.NORMAL_CLOSURE, "done").join(); } - Thread.sleep(1000); } // ──────────────────────────── Cleanup ────────────────────────────