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.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-22 20:00:37 -05:00
1 parent 3c23fff607
commit eeb5fe2b7f
1 file changed
-10
@@ -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 ────────────────────────────