-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run echo test WS server (and http) as a separate build service
- Loading branch information
1 parent
27ff310
commit 88322de
Showing
27 changed files
with
330 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
build/ | ||
|
||
docs/kdoc | ||
|
||
karma.config.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
...bow-websocket-test/src/commonMain/kotlin/org/hildan/krossbow/websocket/test/EchoServer.kt
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...bow-websocket-test/src/commonMain/kotlin/org/hildan/krossbow/websocket/test/HttpServer.kt
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...bsocket-test/src/commonMain/kotlin/org/hildan/krossbow/websocket/test/TestServerConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.hildan.krossbow.websocket.test | ||
|
||
expect fun getTestServerConfig(): TestServerConfig | ||
|
||
data class TestServerConfig( | ||
val host: String, | ||
val wsPort: Int, | ||
val httpPort: Int, | ||
) { | ||
val wsUrl: String = "ws://$host:$wsPort" | ||
|
||
// we need ws:// scheme because the browser web socket doesn't support anything else | ||
val wsUrlWithHttpPort: String = "ws://$host:$httpPort" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
krossbow-websocket-test/src/jsMain/kotlin/org/hildan/krossbow/websocket/test/EchoServerJs.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
krossbow-websocket-test/src/jsMain/kotlin/org/hildan/krossbow/websocket/test/HttpServerJs.kt
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...websocket-test/src/jsMain/kotlin/org/hildan/krossbow/websocket/test/TestServerConfigJs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.hildan.krossbow.websocket.test | ||
|
||
actual fun getTestServerConfig(): TestServerConfig = when (isBrowser()) { | ||
true -> getTestServerConfigBrowser() | ||
false -> getTestServerConfigFromEnv() | ||
} | ||
|
||
// This variable is defined using the webpack DefinePlugin in karma.config.d/<somename>.js | ||
// which is itself generated from Gradle in the test-server plugin | ||
private fun getTestServerConfigBrowser(): TestServerConfig = | ||
js("testServerConfig").unsafeCast<AutobahnConfigJson>().toCommonConfig() | ||
|
||
private external interface AutobahnConfigJson { | ||
val host: String | ||
val wsPort: Int | ||
val httpPort: Int | ||
} | ||
|
||
private fun AutobahnConfigJson.toCommonConfig() = TestServerConfig( | ||
host = host, | ||
wsPort = wsPort, | ||
httpPort = httpPort, | ||
) | ||
|
||
private fun getTestServerConfigFromEnv(): TestServerConfig = TestServerConfig( | ||
host = getMandatoryEnvVar("TEST_SERVER_HOST"), | ||
wsPort = getMandatoryEnvVar("TEST_SERVER_WS_PORT").toInt(), | ||
httpPort = getMandatoryEnvVar("TEST_SERVER_HTTP_PORT").toInt(), | ||
) | ||
|
||
private fun getMandatoryEnvVar(varName: String): String = | ||
process.env[varName] ?: error("Environment variable $varName not provided") | ||
|
||
external val process: Process | ||
|
||
external interface Process { | ||
val env: dynamic | ||
} |
34 changes: 0 additions & 34 deletions
34
...bow-websocket-test/src/jvmMain/kotlin/org/hildan/krossbow/websocket/test/HttpServerJvm.kt
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...bsocket-test/src/jvmMain/kotlin/org/hildan/krossbow/websocket/test/TestServerConfigJvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.hildan.krossbow.websocket.test | ||
|
||
actual fun getTestServerConfig() = TestServerConfig( | ||
host = getMandatoryEnvVar("TEST_SERVER_HOST"), | ||
wsPort = getMandatoryEnvVar("TEST_SERVER_WS_PORT").toInt(), | ||
httpPort = getMandatoryEnvVar("TEST_SERVER_HTTP_PORT").toInt(), | ||
) | ||
|
||
private fun getMandatoryEnvVar(varName: String): String = | ||
System.getenv(varName) ?: error("Environment variable $varName not provided") |
5 changes: 0 additions & 5 deletions
5
...bsocket-test/src/nativeMain/kotlin/org/hildan/krossbow/websocket/test/EchoServerNative.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...bsocket-test/src/nativeMain/kotlin/org/hildan/krossbow/websocket/test/HttpServerNative.kt
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...t-test/src/nativeMain/kotlin/org/hildan/krossbow/websocket/test/TestServerConfigNative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.hildan.krossbow.websocket.test | ||
|
||
import kotlinx.cinterop.* | ||
import platform.posix.* | ||
|
||
actual fun getTestServerConfig() = TestServerConfig( | ||
host = getMandatoryEnvVar("TEST_SERVER_HOST"), | ||
wsPort = getMandatoryEnvVar("TEST_SERVER_WS_PORT").toInt(), | ||
httpPort = getMandatoryEnvVar("TEST_SERVER_HTTP_PORT").toInt(), | ||
) | ||
|
||
@OptIn(ExperimentalForeignApi::class) | ||
private fun getMandatoryEnvVar(varName: String): String = getenv(varName)?.toKString() | ||
?: error("Environment variable $varName not provided") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
rootProject.name = "test-server" | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
include("websocket-test-server") | ||
include("websocket-test-server-gradle-plugin") |
Oops, something went wrong.