feat: parallelize BaseDBTest forEachDB using coroutines
Each EventStore uses an independent in-memory SQLite database, so tests can safely run concurrently. This launches all 16 DB configurations in parallel via coroutines on Dispatchers.Default instead of running them sequentially. https://claude.ai/code/session_01TQRzVTAXBVWRGstcsapA5F
This commit is contained in:
+13
-7
@@ -21,6 +21,9 @@
|
|||||||
package com.vitorpamplona.quartz.nip01Core.store.sqlite
|
package com.vitorpamplona.quartz.nip01Core.store.sqlite
|
||||||
|
|
||||||
import com.vitorpamplona.quartz.utils.Secp256k1Instance
|
import com.vitorpamplona.quartz.utils.Secp256k1Instance
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlin.test.AfterTest
|
import kotlin.test.AfterTest
|
||||||
import kotlin.test.BeforeTest
|
import kotlin.test.BeforeTest
|
||||||
|
|
||||||
@@ -72,12 +75,15 @@ open class BaseDBTest {
|
|||||||
dbs.forEach { it.value.close() }
|
dbs.forEach { it.value.close() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun forEachDB(action: (EventStore) -> Unit) {
|
fun forEachDB(action: (EventStore) -> Unit) =
|
||||||
dbs.forEach {
|
runBlocking {
|
||||||
println("--------------------")
|
dbs.forEach { (key, value) ->
|
||||||
println(it.key)
|
launch(Dispatchers.Default) {
|
||||||
println("--------------------")
|
println("--------------------")
|
||||||
action(it.value)
|
println(key)
|
||||||
|
println("--------------------")
|
||||||
|
action(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user