From cae9130e373294ce8956d1d5546bd3471f488149 Mon Sep 17 00:00:00 2001 From: Pavel Gorgulov Date: Thu, 30 Oct 2025 15:12:03 +0100 Subject: [PATCH] Relocate `WebSocketIntegrationTest` from `commonTest` to `jvmTest` (#352) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With Ktor 3.2.3, tests don’t work correctly with wasm, so the websocket tests were moved to the jvm target as the most important one ## How Has This Been Tested? local ## Breaking Changes None ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [x] Refactoring ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed --- .../websocket}/WebSocketIntegrationTest.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) rename kotlin-sdk-test/src/{commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration => jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket}/WebSocketIntegrationTest.kt (91%) diff --git a/kotlin-sdk-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/WebSocketIntegrationTest.kt b/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt similarity index 91% rename from kotlin-sdk-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/WebSocketIntegrationTest.kt rename to kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt index 2a815dd..6200e08 100644 --- a/kotlin-sdk-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/WebSocketIntegrationTest.kt +++ b/kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/websocket/WebSocketIntegrationTest.kt @@ -1,4 +1,4 @@ -package io.modelcontextprotocol.kotlin.sdk.integration +package io.modelcontextprotocol.kotlin.sdk.integration.kotlin.websocket import io.ktor.client.HttpClient import io.ktor.server.application.install @@ -22,7 +22,6 @@ import io.modelcontextprotocol.kotlin.sdk.server.mcpWebSocket import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.test.runTest import kotlinx.coroutines.withContext -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds @@ -34,7 +33,6 @@ import io.ktor.server.websocket.WebSockets as ServerWebSockets class WebSocketIntegrationTest { @Test - @Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3 fun `client should be able to connect to websocket server 2`() = runTest(timeout = 5.seconds) { var server: EmbeddedServer? = null var client: Client? = null @@ -47,7 +45,7 @@ class WebSocketIntegrationTest { } } finally { client?.close() - server?.stopSuspend(1000, 2000) + server?.stop(1000, 2000) } } @@ -59,7 +57,6 @@ class WebSocketIntegrationTest { * 3. Observe that Client A receives a response related to it. */ @Test - @Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3 fun `single websocket connection`() = runTest(timeout = 5.seconds) { var server: EmbeddedServer? = null var client: Client? = null @@ -75,7 +72,7 @@ class WebSocketIntegrationTest { } } finally { client?.close() - server?.stopSuspend(1000, 2000) + server?.stop(1000, 2000) } } @@ -88,7 +85,6 @@ class WebSocketIntegrationTest { * 4. Observe that Client B (connection #2) receives a response related to sessionId#1. */ @Test - @Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3 fun `multiple websocket connections`() = runTest(timeout = 5.seconds) { var server: EmbeddedServer? = null var clientA: Client? = null @@ -112,7 +108,7 @@ class WebSocketIntegrationTest { } finally { clientA?.close() clientB?.close() - server?.stopSuspend(1000, 2000) + server?.stop(1000, 2000) } } @@ -138,7 +134,7 @@ class WebSocketIntegrationTest { return client } - private suspend fun initServer(): EmbeddedServer { + private fun initServer(): EmbeddedServer { val server = Server( Implementation(name = "websocket-server", version = "1.0.0"), ServerOptions( @@ -175,7 +171,7 @@ class WebSocketIntegrationTest { } } - return ktorServer.startSuspend(wait = false) + return ktorServer.start(wait = false) } /**