From 3f675ca0c968e04f76b01457d4e3e0e26f5e7f6a Mon Sep 17 00:00:00 2001 From: bQUARKz Date: Tue, 29 Sep 2026 16:33:36 +0100 Subject: [PATCH] test: separate LSP initialization and shutdown timeouts --- .../java/p/studio/lsp/services/LspServerLifecycleTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/services/LspServerLifecycleTest.java b/prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/services/LspServerLifecycleTest.java index 9e8ba13d..f03f5114 100644 --- a/prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/services/LspServerLifecycleTest.java +++ b/prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/services/LspServerLifecycleTest.java @@ -8,6 +8,8 @@ import java.net.Socket; import static org.junit.jupiter.api.Assertions.*; class LspServerLifecycleTest { + private static final int INITIALIZATION_TIMEOUT_MS = 10_000; + private static final int SHUTDOWN_TIMEOUT_MS = 2_000; @TempDir Path temporary; @Test void projectEndpointsAreIndependentAndShutdownClosesConnectedSockets() throws Exception { @@ -21,12 +23,15 @@ class LspServerLifecycleTest { assertNotEquals(endpoint.port(), lifecycle.endpoint(second).orElseThrow().port()); assertTrue(lifecycle.endpoint(new LspProjectContext("first", "other-language", temporary)).isEmpty()); try (var socket = new Socket(endpoint.host(), endpoint.port())) { - socket.setSoTimeout(2000); + // Cold LSP/compiler initialization can be slower on a loaded CI worker. + // Keep its budget separate from the socket-closure assertion below. + socket.setSoTimeout(INITIALIZATION_TIMEOUT_MS); String request = "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"rootUri\":\"" + temporary.toUri() + "\",\"capabilities\":{}}}"; byte[] body = request.getBytes(java.nio.charset.StandardCharsets.UTF_8); socket.getOutputStream().write(("Content-Length: " + body.length + "\r\n\r\n").getBytes(java.nio.charset.StandardCharsets.US_ASCII)); socket.getOutputStream().write(body); socket.getOutputStream().flush(); assertNotEquals(-1, socket.getInputStream().read()); + socket.setSoTimeout(SHUTDOWN_TIMEOUT_MS); lifecycle.shutdownServer(first); socket.getInputStream().readAllBytes(); // Buffered reply drains, then EOF; no abandoned client connection. assertTrue(lifecycle.endpoint(first).isEmpty());