Skip to content

Commit db2ba73

Browse files
committed
More timeout for js tests and logging for stressActing
1 parent db65a50 commit db2ba73

File tree

4 files changed

+89
-2
lines changed

4 files changed

+89
-2
lines changed

kotlin-js-store/package-lock.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kotlin-js-store/wasm/package-lock.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

krpc/krpc-core/src/commonTest/kotlin/kotlinx/rpc/krpc/KrpcReceiveHandlerTest.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44

55
package kotlinx.rpc.krpc
66

7+
import kotlinx.atomicfu.atomic
78
import kotlinx.coroutines.CoroutineScope
9+
import kotlinx.coroutines.Dispatchers
810
import kotlinx.coroutines.ExperimentalCoroutinesApi
911
import kotlinx.coroutines.Job
1012
import kotlinx.coroutines.cancelAndJoin
1113
import kotlinx.coroutines.channels.Channel
14+
import kotlinx.coroutines.delay
1215
import kotlinx.coroutines.job
1316
import kotlinx.coroutines.joinAll
1417
import kotlinx.coroutines.launch
1518
import kotlinx.coroutines.test.TestResult
1619
import kotlinx.coroutines.test.TestScope
20+
import kotlinx.coroutines.withContext
1721
import kotlinx.coroutines.yield
1822
import kotlinx.rpc.krpc.internal.HandlerKey
1923
import kotlinx.rpc.krpc.internal.KrpcActingReceiveHandler
@@ -162,12 +166,24 @@ internal class KrpcReceiveHandlerTest : KrpcReceiveHandlerBaseTest() {
162166
}
163167
}
164168

169+
val counter = Counter()
170+
val printJob = launch {
171+
while (true) {
172+
withContext(Dispatchers.Default) {
173+
delay(5.seconds)
174+
}
175+
println("Collected: ${collected.size}, launches: ${counter.launches.value}, total: ${counter.total.value}")
176+
}
177+
}
178+
165179
val iterations = stressIterations
166180
List(iterations) {
167181
launch {
168182
repeat(100) {
169183
sender.sendMessage(KrpcTransportMessage.StringMessage("Hello"))
184+
counter.total.incrementAndGet()
170185
}
186+
counter.launches.incrementAndGet()
171187
}
172188
}.joinAll()
173189

@@ -179,11 +195,17 @@ internal class KrpcReceiveHandlerTest : KrpcReceiveHandlerBaseTest() {
179195
actorJob.cancelAndJoin()
180196
senderJob.cancelAndJoin()
181197
windowJob.cancelAndJoin()
198+
printJob.cancelAndJoin()
182199
}
183200
}
184201
}
185202

186203
internal abstract class KrpcReceiveHandlerBaseTest {
204+
class Counter {
205+
val launches = atomic(0)
206+
val total = atomic(0)
207+
}
208+
187209
protected fun String.asMessage() = KrpcGenericMessage(
188210
connectionId = null,
189211
pluginParams = mapOf(KrpcPluginKey.WINDOW_KEY to this)

krpc/krpc-test/src/commonTest/kotlin/kotlinx/rpc/krpc/test/BackPressureTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class BackPressureTest : BackPressureTestBase() {
9090
abstract class BackPressureTestBase {
9191
protected fun runServerTest(
9292
perCallBufferSize: Int,
93-
timeout: Duration = 10.seconds,
93+
timeout: Duration = 30.seconds,
9494
) = runTest(perCallBufferSize, timeout) { service, impl ->
9595
var counter = 0
9696
val flowList = async {
@@ -123,7 +123,7 @@ abstract class BackPressureTestBase {
123123

124124
protected fun runClientTest(
125125
perCallBufferSize: Int,
126-
timeout: Duration = 10.seconds,
126+
timeout: Duration = 30.seconds,
127127
) = runTest(perCallBufferSize, timeout) { service, impl ->
128128
var counter = 0
129129
val flowList = async {

0 commit comments

Comments
 (0)