Skip to content

Commit 9908822

Browse files
authored
misc: Kotlin/Native IO implementation (#96)
1 parent ef8137a commit 9908822

File tree

25 files changed

+468
-110
lines changed

25 files changed

+468
-110
lines changed

aws-crt-kotlin/api/aws-crt-kotlin.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public final class aws/sdk/kotlin/crt/CRT {
66
public static final field INSTANCE Laws/sdk/kotlin/crt/CRT;
77
public final fun errorName (I)Ljava/lang/String;
88
public final fun errorString (I)Ljava/lang/String;
9-
public final fun initRuntime (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10-
public static synthetic fun initRuntime$default (Laws/sdk/kotlin/crt/CRT;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
9+
public final fun initRuntime (Lkotlin/jvm/functions/Function1;)V
10+
public static synthetic fun initRuntime$default (Laws/sdk/kotlin/crt/CRT;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
1111
public final fun isHttpErrorRetryable (I)Z
1212
public final fun lastError ()I
1313
public final fun nativeMemory ()J

aws-crt-kotlin/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ kotlin {
8888
}
8989
}
9090

91+
val commonTest by getting {
92+
dependencies {
93+
implementation(libs.kotlinx.coroutines.test)
94+
}
95+
}
96+
9197
val jvmMain by getting {
9298
dependencies {
9399
implementation(libs.crt.java)

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/Utils.kt

Lines changed: 0 additions & 16 deletions
This file was deleted.

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/auth/credentials/CredentialsProviderTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import aws.sdk.kotlin.crt.CrtTest
99
import aws.sdk.kotlin.crt.io.ClientBootstrap
1010
import aws.sdk.kotlin.crt.io.EventLoopGroup
1111
import aws.sdk.kotlin.crt.io.HostResolver
12-
import aws.sdk.kotlin.crt.runSuspendTest
12+
import kotlinx.coroutines.test.runTest
1313
import kotlin.test.Ignore
1414
import kotlin.test.Test
1515
import kotlin.test.assertEquals
@@ -19,7 +19,7 @@ class CredentialsProviderTest : CrtTest() {
1919

2020
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
2121
@Test
22-
fun testStaticProvider() = runSuspendTest {
22+
fun testStaticProvider() = runTest {
2323
val provider = StaticCredentialsProvider.fromCredentials(EXPECTED_CREDENTIALS)
2424
val actual = provider.getCredentials()
2525
assertEquals(EXPECTED_CREDENTIALS, actual)
@@ -44,7 +44,7 @@ class CredentialsProviderTest : CrtTest() {
4444

4545
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
4646
@Test
47-
fun testCacheStatic() = runSuspendTest {
47+
fun testCacheStatic() = runTest {
4848
val provider = CachedCredentialsProvider.build {
4949
source = StaticCredentialsProvider.fromCredentials(EXPECTED_CREDENTIALS)
5050
refreshTimeInMilliseconds = 900

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/auth/signing/SigningTest.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import aws.sdk.kotlin.crt.http.HttpRequest
1313
import aws.sdk.kotlin.crt.http.HttpRequestBodyStream
1414
import aws.sdk.kotlin.crt.http.headers
1515
import aws.sdk.kotlin.crt.io.Uri
16+
import kotlinx.coroutines.test.runTest
1617
import kotlin.test.*
1718

1819
// ported over from crt-java
@@ -56,7 +57,7 @@ class SigningTest : CrtTest() {
5657

5758
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
5859
@Test
59-
fun testSigningSuccess() = runSuspendTest {
60+
fun testSigningSuccess() = runTest {
6061
StaticCredentialsProvider.build {
6162
accessKeyId = TEST_ACCESS_KEY_ID
6263
secretAccessKey = TEST_SECRET_ACCESS_KEY
@@ -82,7 +83,7 @@ class SigningTest : CrtTest() {
8283

8384
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
8485
@Test
85-
fun testQuerySigningSuccess() = runSuspendTest {
86+
fun testQuerySigningSuccess() = runTest {
8687
StaticCredentialsProvider.build {
8788
accessKeyId = TEST_ACCESS_KEY_ID
8889
secretAccessKey = TEST_SECRET_ACCESS_KEY
@@ -114,7 +115,7 @@ class SigningTest : CrtTest() {
114115

115116
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
116117
@Test
117-
fun testSigningBasicSigV4() = runSuspendTest {
118+
fun testSigningBasicSigV4() = runTest {
118119
StaticCredentialsProvider.build {
119120
accessKeyId = TEST_ACCESS_KEY_ID
120121
secretAccessKey = TEST_SECRET_ACCESS_KEY
@@ -147,7 +148,7 @@ class SigningTest : CrtTest() {
147148

148149
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
149150
@Test
150-
fun testSigningFailureBadRequest() = runSuspendTest {
151+
fun testSigningFailureBadRequest() = runTest {
151152
StaticCredentialsProvider.build {
152153
accessKeyId = TEST_ACCESS_KEY_ID
153154
secretAccessKey = TEST_SECRET_ACCESS_KEY
@@ -174,7 +175,7 @@ class SigningTest : CrtTest() {
174175

175176
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
176177
@Test
177-
fun testSigningSigV4Asymmetric() = runSuspendTest {
178+
fun testSigningSigV4Asymmetric() = runTest {
178179
StaticCredentialsProvider.build {
179180
accessKeyId = TEST_ACCESS_KEY_ID
180181
secretAccessKey = TEST_SECRET_ACCESS_KEY
@@ -202,7 +203,7 @@ class SigningTest : CrtTest() {
202203

203204
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
204205
@Test
205-
fun testSigningChunkTrailingHeaders() = runSuspendTest {
206+
fun testSigningChunkTrailingHeaders() = runTest {
206207
StaticCredentialsProvider.build {
207208
accessKeyId = "AKID"
208209
secretAccessKey = "SECRET"

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/http/HttpClientConnectionTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ package aws.sdk.kotlin.crt.http
77

88
import aws.sdk.kotlin.crt.CrtTest
99
import aws.sdk.kotlin.crt.io.*
10-
import aws.sdk.kotlin.crt.runSuspendTest
1110
import aws.sdk.kotlin.crt.use
11+
import kotlinx.coroutines.test.runTest
1212
import kotlinx.coroutines.withTimeout
1313
import kotlin.test.*
1414
import kotlin.time.measureTime
1515

1616
class HttpClientConnectionTest : CrtTest() {
1717
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
1818
@Test
19-
fun testDefaults() = runSuspendTest {
19+
fun testDefaults() = runTest {
2020
val uri = Uri.parse("https://aws-crt-test-stuff.s3.amazonaws.com")
2121
val socketOpts = SocketOptions()
2222
val elg = EventLoopGroup()
@@ -56,7 +56,7 @@ class HttpClientConnectionTest : CrtTest() {
5656

5757
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
5858
@Test
59-
fun testHttpConnection() = runSuspendTest {
59+
fun testHttpConnection() = runTest {
6060
// S3
6161
assertConnect("https://aws-crt-test-stuff.s3.amazonaws.com")
6262
assertConnect("http://aws-crt-test-stuff.s3.amazonaws.com")

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/io/ClientBootstrapTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
package aws.sdk.kotlin.crt.io
77

88
import aws.sdk.kotlin.crt.CrtTest
9-
import aws.sdk.kotlin.crt.runSuspendTest
10-
import kotlin.test.Ignore
9+
import kotlinx.coroutines.test.runTest
1110
import kotlin.test.Test
1211

1312
class ClientBootstrapTest : CrtTest() {
14-
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
1513
@Test
16-
fun createDestroy() = runSuspendTest {
14+
fun createDestroy() = runTest {
1715
val elg = EventLoopGroup()
1816
val hr = HostResolver(elg)
1917
val bootstrap = ClientBootstrap(elg, hr)

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/io/EventLoopGroupTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
package aws.sdk.kotlin.crt.io
77

88
import aws.sdk.kotlin.crt.CrtTest
9-
import aws.sdk.kotlin.crt.runSuspendTest
10-
import kotlin.test.Ignore
9+
import kotlinx.coroutines.test.runTest
1110
import kotlin.test.Test
1211

1312
class EventLoopGroupTest : CrtTest() {
14-
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
1513
@Test
16-
fun createDestroy() = runSuspendTest {
14+
fun createDestroy() = runTest {
1715
val elg = EventLoopGroup()
1816
elg.close()
1917
}

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/io/HostResolverTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
package aws.sdk.kotlin.crt.io
77

88
import aws.sdk.kotlin.crt.CrtTest
9-
import aws.sdk.kotlin.crt.runSuspendTest
109
import aws.sdk.kotlin.crt.use
11-
import kotlin.test.Ignore
10+
import kotlinx.coroutines.test.runTest
1211
import kotlin.test.Test
1312

1413
class HostResolverTest : CrtTest() {
15-
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
1614
@Test
17-
fun createDestroy() = runSuspendTest {
15+
fun createDestroy() = runTest {
1816
EventLoopGroup().use { elg ->
1917
val hr = HostResolver(elg)
2018
hr.close()

aws-crt-kotlin/common/test/aws/sdk/kotlin/crt/io/TlsContextTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
package aws.sdk.kotlin.crt.io
77

88
import aws.sdk.kotlin.crt.CrtTest
9-
import aws.sdk.kotlin.crt.runSuspendTest
10-
import kotlin.test.Ignore
9+
import kotlinx.coroutines.test.runTest
1110
import kotlin.test.Test
1211

1312
class TlsContextTest : CrtTest() {
14-
@Ignore // FIXME Enable when Kotlin/Native implementation is complete
1513
@Test
16-
fun createDestroy() = runSuspendTest {
14+
fun createDestroy() = runTest {
1715
val ctx = TlsContext()
1816
ctx.close()
1917
}

0 commit comments

Comments
 (0)