Skip to content

Commit 65d21a1

Browse files
authored
Bump Misk and Kotlin 2 (#419)
- [x] Fix Kotlin Coroutines deprecation warnings currently failing tests
1 parent 65b8812 commit 65d21a1

File tree

5 files changed

+173
-226
lines changed

5 files changed

+173
-226
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
GROUP=app.cash.backfila
22

3-
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
3+
org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=5g -Dfile.encoding=UTF-8

gradle/libs.versions.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[versions]
22
jooq = "3.18.25"
3-
kotlin = "1.9.23"
3+
kotlin = "2.0.21"
4+
kotlinxCoroutines = "1.10.1"
45
ktlint = "0.47.1"
5-
misk = "2025.01.09.184726-680bca2"
6+
misk = "2025.02.11.123913-8a41324"
67
okhttp = "5.0.0-alpha.14"
78
sqldelight = "2.0.2"
89
wire = "5.2.1"
@@ -63,9 +64,9 @@ kotlinPoet = { module = "com.squareup:kotlinpoet", version = "1.18.1" }
6364
kotlinReflection = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
6465
kotlinStdLib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
6566
kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
66-
kotlinxCoroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.3" }
67-
kotlinxCoroutinesLogging = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version = "1.6.3" }
68-
kotlinxCoroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version = "1.6.3" }
67+
kotlinxCoroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
68+
kotlinxCoroutinesLogging = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "kotlinxCoroutines" }
69+
kotlinxCoroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
6970
kotlinxHtml = { module = "org.jetbrains.kotlinx:kotlinx-html-jvm", version = "0.12.0" }
7071
misk = { module = "com.squareup.misk:misk", version.ref = "misk" }
7172
miskActions = { module = "com.squareup.misk:misk-actions", version.ref = "misk" }

service/src/test/kotlin/app/cash/backfila/service/BackfillRunnerTest.kt

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit
3131
import javax.inject.Inject
3232
import kotlinx.coroutines.delay
3333
import kotlinx.coroutines.launch
34+
import kotlinx.coroutines.test.runTest
3435
import misk.hibernate.Transacter
3536
import misk.hibernate.load
3637
import misk.scope.ActionScope
@@ -84,7 +85,7 @@ class BackfillRunnerTest {
8485
assertThat(partition.run_state).isEqualTo(BackfillState.RUNNING)
8586
}
8687

87-
runBlockingTestCancellable {
88+
runTest {
8889
runner.start(this)
8990
}
9091

@@ -111,7 +112,7 @@ class BackfillRunnerTest {
111112
assertThat(partition.pkey_cursor).isNull()
112113
assertThat(partition.state).isEqualTo(BackfillState.RUNNING)
113114

114-
runBlockingTestCancellable {
115+
runTest {
115116
runner.start(this)
116117
}
117118

@@ -147,7 +148,7 @@ class BackfillRunnerTest {
147148
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
148149
val runner = startBackfill(numThreads = 1)
149150

150-
runBlockingTestCancellable {
151+
runTest {
151152
runner.start(this)
152153

153154
// We should only get numthreads=1 calls in parallel, then it must wait for more room.
@@ -170,7 +171,7 @@ class BackfillRunnerTest {
170171
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
171172
val runner = startBackfill(numThreads = 1)
172173

173-
runBlockingTestCancellable {
174+
runTest {
174175
runner.start(this)
175176
val firstRequest = fakeBackfilaClientServiceClient.runBatchRequests.receive()
176177
assertThat(firstRequest.parameters).containsEntry("cheese", "cheddar".encodeUtf8())
@@ -188,7 +189,7 @@ class BackfillRunnerTest {
188189
)
189190
}
190191

191-
runBlockingTestCancellable {
192+
runTest {
192193
runner.start(this)
193194

194195
val firstRequest = fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -201,7 +202,7 @@ class BackfillRunnerTest {
201202
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
202203
val runner = startBackfill(numThreads = 3)
203204

204-
runBlockingTestCancellable {
205+
runTest {
205206
runner.start(this)
206207

207208
// We should only get numthreads=3 calls in parallel, then it must wait for more room.
@@ -256,7 +257,7 @@ class BackfillRunnerTest {
256257
partition.precomputing_done = true
257258
}
258259

259-
runBlockingTestCancellable {
260+
runTest {
260261
runner.start(this)
261262

262263
assertThat(fakeBackfilaClientServiceClient.getNextBatchRangeRequests.receive()).isNotNull()
@@ -296,7 +297,7 @@ class BackfillRunnerTest {
296297
partition.precomputing_done = true
297298
}
298299

299-
runBlockingTestCancellable {
300+
runTest {
300301
launch { runner.start(this) }
301302

302303
// Process 4 getNextBatchRangeRequests
@@ -376,7 +377,7 @@ class BackfillRunnerTest {
376377
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
377378
val runner = startBackfill(numThreads = 1)
378379

379-
runBlockingTestCancellable {
380+
runTest {
380381
launch { runner.start(this) }
381382
// Leave awaiting run batch response
382383
fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -407,7 +408,7 @@ class BackfillRunnerTest {
407408
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
408409
val runner = startBackfill(numThreads = 2)
409410

410-
runBlockingTestCancellable {
411+
runTest {
411412
launch { runner.start(this) }
412413

413414
val firstRequest = fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -451,7 +452,7 @@ class BackfillRunnerTest {
451452
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
452453
val runner = startBackfill(numThreads = 1)
453454

454-
runBlockingTestCancellable {
455+
runTest {
455456
launch { runner.start(this) }
456457

457458
val firstRequest = fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -492,7 +493,7 @@ class BackfillRunnerTest {
492493
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
493494
val runner = startBackfill(numThreads = 2)
494495

495-
runBlockingTestCancellable {
496+
runTest {
496497
launch { runner.start(this) }
497498

498499
val firstRequest = fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -550,7 +551,7 @@ class BackfillRunnerTest {
550551
partition.precomputing_done = true
551552
}
552553

553-
runBlockingTestCancellable {
554+
runTest {
554555
launch { runner.start(this) }
555556

556557
assertThat(fakeBackfilaClientServiceClient.getNextBatchRangeRequests.receive()).isNotNull()
@@ -576,7 +577,7 @@ class BackfillRunnerTest {
576577
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
577578
val runner = startBackfill(numThreads = 1)
578579

579-
runBlockingTestCancellable {
580+
runTest {
580581
launch { runner.start(this) }
581582

582583
fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -591,7 +592,7 @@ class BackfillRunnerTest {
591592
// Nothing sent yet - the backoff is 1000ms
592593
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNull()
593594
delay(500)
594-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
595+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
595596
fakeBackfilaClientServiceClient.runBatchResponses.send(
596597
Result.success(RunBatchResponse.Builder().build()),
597598
)
@@ -609,7 +610,7 @@ class BackfillRunnerTest {
609610
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
610611
val runner = startBackfill(numThreads = 1, extraSleepMs = 1000L)
611612

612-
runBlockingTestCancellable {
613+
runTest {
613614
launch { runner.start(this) }
614615

615616
fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -621,7 +622,7 @@ class BackfillRunnerTest {
621622
// Nothing sent yet - the backoff is 1000ms
622623
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNull()
623624
delay(500)
624-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
625+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
625626
fakeBackfilaClientServiceClient.runBatchResponses.send(
626627
Result.success(RunBatchResponse.Builder().build()),
627628
)
@@ -639,7 +640,7 @@ class BackfillRunnerTest {
639640
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
640641
val runner = startBackfill(numThreads = 2, extraSleepMs = 1000L)
641642

642-
runBlockingTestCancellable {
643+
runTest {
643644
launch { runner.start(this) }
644645

645646
fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -655,7 +656,7 @@ class BackfillRunnerTest {
655656
// Nothing sent yet - the backoff is 1000ms
656657
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNull()
657658
delay(500)
658-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
659+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
659660
fakeBackfilaClientServiceClient.runBatchResponses.send(
660661
Result.success(RunBatchResponse.Builder().build()),
661662
)
@@ -678,7 +679,7 @@ class BackfillRunnerTest {
678679
partition.precomputing_done = true
679680
}
680681

681-
runBlockingTestCancellable {
682+
runTest {
682683
launch { runner.start(this) }
683684

684685
assertThat(fakeBackfilaClientServiceClient.getNextBatchRangeRequests.receive()).isNotNull()
@@ -697,9 +698,9 @@ class BackfillRunnerTest {
697698
// The first batch has no matching records, so no delay is added.
698699
// The second batch, with nonzero matching count, gets run immediately.
699700
val runBatchRequest =
700-
fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()
701+
fakeBackfilaClientServiceClient.runBatchRequests.receive()
701702
assertThat(runBatchRequest).isNotNull()
702-
assertThat(runBatchRequest!!.batch_range).isEqualTo(
703+
assertThat(runBatchRequest.batch_range).isEqualTo(
703704
KeyRange("100".encodeUtf8(), "199".encodeUtf8()),
704705
)
705706
runner.stop()
@@ -710,13 +711,13 @@ class BackfillRunnerTest {
710711
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
711712
val runner = startBackfill(numThreads = 3)
712713

713-
runBlockingTestCancellable {
714+
runTest {
714715
launch { runner.start(this) }
715716

716717
// We should only get numthreads=3 calls in parallel, then it must wait for more room.
717-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
718-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
719-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
718+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
719+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
720+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
720721
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNull()
721722

722723
scope.fakeCaller(user = "molly") {
@@ -735,9 +736,9 @@ class BackfillRunnerTest {
735736
fakeBackfilaClientServiceClient.runBatchResponses.send(
736737
Result.success(RunBatchResponse.Builder().build()),
737738
)
738-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
739-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
740-
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNotNull()
739+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
740+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
741+
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.receive()).isNotNull()
741742
assertThat(fakeBackfilaClientServiceClient.runBatchRequests.tryReceive().getOrNull()).isNull()
742743
runner.stop()
743744
}
@@ -753,7 +754,7 @@ class BackfillRunnerTest {
753754
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
754755
val runner = startBackfill(numThreads = 1)
755756

756-
runBlockingTestCancellable {
757+
runTest {
757758
launch { runner.start(this) }
758759

759760
val initialRequest = fakeBackfilaClientServiceClient.runBatchRequests.receive()
@@ -834,7 +835,7 @@ class BackfillRunnerTest {
834835
fakeBackfilaClientServiceClient.dontBlockGetNextBatch()
835836
val runner = startBackfill(numThreads = 3)
836837

837-
runBlockingTestCancellable {
838+
runTest {
838839
launch { runner.start(this) }
839840

840841
// We should only get numthreads=3 calls in parallel, then it must wait for more room.

service/src/test/kotlin/app/cash/backfila/service/RunBlockingTestCancellable.kt

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

0 commit comments

Comments
 (0)