Skip to content

Commit 6129c94

Browse files
committed
Speed up stress tests and use stressTestMultiplier for nightly tests
1 parent f2239e1 commit 6129c94

File tree

9 files changed

+81
-36
lines changed

9 files changed

+81
-36
lines changed

core/kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/channels/ChannelLinearizabilityTest.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ import com.devexperts.dxlab.lincheck.annotations.Operation
2121
import com.devexperts.dxlab.lincheck.annotations.Param
2222
import com.devexperts.dxlab.lincheck.annotations.Reset
2323
import com.devexperts.dxlab.lincheck.paramgen.IntGen
24-
import com.devexperts.dxlab.lincheck.stress.StressCTest
25-
import kotlinx.coroutines.experimental.LinTesting
26-
import kotlinx.coroutines.experimental.LinVerifier
24+
import com.devexperts.dxlab.lincheck.stress.*
25+
import kotlinx.coroutines.experimental.*
2726
import org.junit.Test
2827

29-
@StressCTest(iterations = 100, actorsPerThread = arrayOf("1:3", "1:3", "1:3"), verifier = LinVerifier::class)
3028
@Param(name = "value", gen = IntGen::class, conf = "1:3")
31-
class ChannelLinearizabilityTest {
29+
class ChannelLinearizabilityTest : TestBase() {
3230
private val lt = LinTesting()
3331
private lateinit var channel: Channel<Int>
3432

@@ -63,6 +61,13 @@ class ChannelLinearizabilityTest {
6361

6462
@Test
6563
fun testLinearizability() {
66-
LinChecker.check(ChannelLinearizabilityTest::class.java)
64+
val options = StressOptions()
65+
.iterations(100)
66+
.invocationsPerIteration(1000 * stressTestMultiplier)
67+
.addThread(1, 3)
68+
.addThread(1, 3)
69+
.addThread(1, 3)
70+
.verifier(LinVerifier::class.java)
71+
LinChecker.check(ChannelLinearizabilityTest::class.java, options)
6772
}
6873
}

core/kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/internal/LockFreeListLinearizabilityTest.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import com.devexperts.dxlab.lincheck.*
2020
import com.devexperts.dxlab.lincheck.annotations.*
2121
import com.devexperts.dxlab.lincheck.paramgen.*
2222
import com.devexperts.dxlab.lincheck.stress.*
23+
import kotlinx.coroutines.experimental.*
2324
import kotlin.test.*
2425

25-
@StressCTest(iterations = 100, actorsPerThread = ["1:2", "1:2", "1:2", "1:2"])
2626
@Param(name = "value", gen = IntGen::class, conf = "1:3")
27-
class LockFreeListLinearizabilityTest {
27+
class LockFreeListLinearizabilityTest : TestBase() {
2828
class Node(val value: Int): LockFreeLinkedListNode()
2929

3030
lateinit var q: LockFreeLinkedListHead
@@ -60,6 +60,13 @@ class LockFreeListLinearizabilityTest {
6060

6161
@Test
6262
fun testAddRemoveLinearizability() {
63-
LinChecker.check(LockFreeListLinearizabilityTest::class.java)
63+
val options = StressOptions()
64+
.iterations(100)
65+
.invocationsPerIteration(1000 * stressTestMultiplier)
66+
.addThread(1, 2)
67+
.addThread(1, 2)
68+
.addThread(1, 2)
69+
.addThread(1, 2)
70+
LinChecker.check(LockFreeListLinearizabilityTest::class.java, options)
6471
}
6572
}

core/kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/internal/LockFreeMPSCQueueLinearizabilityTest.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import com.devexperts.dxlab.lincheck.*
2020
import com.devexperts.dxlab.lincheck.annotations.*
2121
import com.devexperts.dxlab.lincheck.paramgen.*
2222
import com.devexperts.dxlab.lincheck.stress.*
23+
import kotlinx.coroutines.experimental.*
2324
import kotlin.test.*
2425

25-
@StressCTest(iterations = 100, actorsPerThread = ["1:3", "1:3", "1:3"])
2626
@OpGroupConfigs(OpGroupConfig(name = "consumer", nonParallel = true))
2727
@Param(name = "value", gen = IntGen::class, conf = "1:3")
28-
class LockFreeMPSCQueueLinearizabilityTest {
28+
class LockFreeMPSCQueueLinearizabilityTest : TestBase() {
2929
private lateinit var q: LockFreeMPSCQueue<Int>
3030

3131
@Reset
@@ -44,6 +44,12 @@ class LockFreeMPSCQueueLinearizabilityTest {
4444

4545
@Test
4646
fun testLinearizability() {
47-
LinChecker.check(LockFreeMPSCQueueLinearizabilityTest::class.java)
47+
val options = StressOptions()
48+
.iterations(100)
49+
.invocationsPerIteration(1000 * stressTestMultiplier)
50+
.addThread(1, 3)
51+
.addThread(1, 3)
52+
.addThread(1, 3)
53+
LinChecker.check(LockFreeMPSCQueueLinearizabilityTest::class.java, options)
4854
}
4955
}

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/BufferReleaseLinearizabilityTest.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import com.devexperts.dxlab.lincheck.stress.*
66
import kotlinx.coroutines.experimental.*
77
import org.junit.*
88

9-
@StressCTest(iterations = 200, invocationsPerIteration = 20_000, actorsPerThread = arrayOf("1:2", "1:2"), verifier = LinVerifier::class)
109
@OpGroupConfigs(
1110
OpGroupConfig(name = "write", nonParallel = true),
1211
OpGroupConfig(name = "read", nonParallel = true)
1312
)
14-
class BufferReleaseLinearizabilityTest {
13+
class BufferReleaseLinearizabilityTest : TestBase() {
1514
private lateinit var ch: ByteChannel
1615

1716
private val lr = LinTesting()
@@ -38,6 +37,11 @@ class BufferReleaseLinearizabilityTest {
3837

3938
@Test
4039
fun test() {
41-
LinChecker.check(BufferReleaseLinearizabilityTest::class.java)
40+
val options = StressOptions()
41+
.iterations(100)
42+
.invocationsPerIteration(1000 * stressTestMultiplier)
43+
.addThread(1, 2)
44+
.addThread(1, 2)
45+
LinChecker.check(BufferReleaseLinearizabilityTest::class.java, options)
4246
}
4347
}

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/ByteBufferChannelTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import kotlin.test.assertNotEquals
2727
import kotlin.test.assertTrue
2828
import kotlin.test.fail
2929

30-
class ByteBufferChannelTest {
30+
class ByteBufferChannelTest : TestBase() {
3131
@get:Rule
3232
val timeout = Timeout(100, TimeUnit.SECONDS)
3333

@@ -634,7 +634,7 @@ class ByteBufferChannelTest {
634634

635635
@Test
636636
fun testCopyLarge() {
637-
val count = 1024 * 256 // * 8192 = 2Gb
637+
val count = 100 * 256 * stressTestMultiplier // * 8192
638638

639639
launch {
640640
val bb = ByteBuffer.allocate(8192)
@@ -691,7 +691,7 @@ class ByteBufferChannelTest {
691691

692692
@Test
693693
fun testJoinToLarge() {
694-
val count = 1024 * 256 // * 8192 = 2Gb
694+
val count = 100 * 256 * stressTestMultiplier // * 8192
695695

696696
val writerJob = launch {
697697
val bb = ByteBuffer.allocate(8192)
@@ -776,7 +776,7 @@ class ByteBufferChannelTest {
776776
}
777777

778778
try {
779-
(1..1_000_000).map {
779+
(1..100_000 * stressTestMultiplier).map {
780780
async(exec) {
781781
val channel = ByteBufferChannel(autoFlush = false, pool = pool)
782782
val job = launch(exec) {
@@ -935,7 +935,7 @@ class ByteBufferChannelTest {
935935

936936
@Test
937937
fun writeThenReadStress() = runBlocking<Unit> {
938-
for (i in 1..500_000) {
938+
for (i in 1..50_000 * stressTestMultiplier) {
939939
val a = ByteBufferChannel(false, pool)
940940

941941
val w = launch {
@@ -955,7 +955,7 @@ class ByteBufferChannelTest {
955955

956956
@Test
957957
fun joinToEmptyStress() = runBlocking<Unit> {
958-
for (i in 1..500_000) {
958+
for (i in 1..50_000 * stressTestMultiplier) {
959959
val a = ByteBufferChannel(false, pool)
960960

961961
launch(coroutineContext) {
@@ -970,7 +970,7 @@ class ByteBufferChannelTest {
970970

971971
@Test
972972
fun testJoinToStress() = runBlocking<Unit> {
973-
for (i in 1..100000) {
973+
for (i in 1..10000 * stressTestMultiplier) {
974974
val child = ByteBufferChannel(false, pool)
975975
val writer = launch {
976976
child.writeLong(999 + i.toLong())
@@ -988,7 +988,7 @@ class ByteBufferChannelTest {
988988

989989
@Test
990990
fun testSequentialJoin() = runBlocking<Unit> {
991-
val steps = 200_000
991+
val steps = 20_000 * stressTestMultiplier
992992

993993
val pipeline = launch(coroutineContext) {
994994
for (i in 1..steps) {
@@ -1013,7 +1013,7 @@ class ByteBufferChannelTest {
10131013

10141014
@Test
10151015
fun testSequentialJoinYield() = runBlocking<Unit> {
1016-
val steps = 200_000
1016+
val steps = 20_000 * stressTestMultiplier
10171017

10181018
val pipeline = launch(coroutineContext) {
10191019
for (i in 1..steps) {

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/ByteChannelJoinLinearizabilityTest.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import com.devexperts.dxlab.lincheck.stress.*
66
import kotlinx.coroutines.experimental.*
77
import org.junit.*
88

9-
@StressCTest(iterations = 200, invocationsPerIteration = 2_000, actorsPerThread = arrayOf("1:1", "1:1", "1:1"), verifier = LinVerifier::class)
109
@OpGroupConfigs(
1110
OpGroupConfig(name = "write", nonParallel = true),
1211
OpGroupConfig(name = "read1", nonParallel = true),
1312
OpGroupConfig(name = "read2", nonParallel = true)
1413
)
15-
class ByteChannelJoinLinearizabilityTest {
14+
class ByteChannelJoinLinearizabilityTest : TestBase() {
1615
private lateinit var from: ByteChannel
1716
private lateinit var to: ByteChannel
1817

@@ -42,6 +41,13 @@ class ByteChannelJoinLinearizabilityTest {
4241

4342
@Test
4443
fun test() {
45-
LinChecker.check(ByteChannelJoinLinearizabilityTest::class.java)
44+
val options = StressOptions()
45+
.iterations(100)
46+
.invocationsPerIteration(1000 * stressTestMultiplier)
47+
.addThread(1, 1)
48+
.addThread(1, 1)
49+
.addThread(1, 1)
50+
.verifier(LinVerifier::class.java)
51+
LinChecker.check(ByteChannelJoinLinearizabilityTest::class.java, options)
4652
}
4753
}

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/ByteChannelJoinNoAutoFlushLinearizabilityTest.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import com.devexperts.dxlab.lincheck.stress.*
66
import kotlinx.coroutines.experimental.*
77
import org.junit.*
88

9-
@StressCTest(iterations = 200, invocationsPerIteration = 2_000, actorsPerThread = arrayOf("1:2", "1:1", "1:1"), verifier = LinVerifier::class)
109
@OpGroupConfigs(
1110
OpGroupConfig(name = "write", nonParallel = true),
1211
OpGroupConfig(name = "read1", nonParallel = true),
1312
OpGroupConfig(name = "read2", nonParallel = true)
1413
)
15-
class ByteChannelJoinNoAutoFlushLinearizabilityTest {
14+
class ByteChannelJoinNoAutoFlushLinearizabilityTest : TestBase() {
1615
private lateinit var from: ByteChannel
1716
private lateinit var to: ByteChannel
1817

@@ -42,6 +41,13 @@ class ByteChannelJoinNoAutoFlushLinearizabilityTest {
4241

4342
@Test
4443
fun test() {
45-
LinChecker.check(ByteChannelJoinNoAutoFlushLinearizabilityTest::class.java)
44+
val options = StressOptions()
45+
.iterations(100)
46+
.invocationsPerIteration(1000 * stressTestMultiplier)
47+
.addThread(1, 2)
48+
.addThread(1, 1)
49+
.addThread(1, 1)
50+
.verifier(LinVerifier::class.java)
51+
LinChecker.check(ByteChannelJoinNoAutoFlushLinearizabilityTest::class.java, options)
4652
}
4753
}

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/ByteChannelLinearizabilityTest.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import com.devexperts.dxlab.lincheck.stress.*
77
import kotlinx.coroutines.experimental.*
88
import org.junit.*
99

10-
@StressCTest(iterations = 100, actorsPerThread = arrayOf("1:1", "1:1", "1:1"), verifier = LinVerifier::class)
1110
@Param(name = "value", gen = IntGen::class, conf = "1:8192")
1211
@OpGroupConfigs(
1312
OpGroupConfig(name = "write", nonParallel = true),
1413
OpGroupConfig(name = "read", nonParallel = true)
1514
)
16-
class ByteChannelLinearizabilityTest {
15+
class ByteChannelLinearizabilityTest : TestBase() {
1716
private lateinit var channel: ByteChannel
1817
private val lr = LinTesting()
1918

@@ -54,6 +53,13 @@ class ByteChannelLinearizabilityTest {
5453

5554
@Test
5655
fun test() {
57-
LinChecker.check(ByteChannelLinearizabilityTest::class.java)
56+
val options = StressOptions()
57+
.iterations(100)
58+
.invocationsPerIteration(1000 * stressTestMultiplier)
59+
.addThread(1, 1)
60+
.addThread(1, 1)
61+
.addThread(1, 1)
62+
.verifier(LinVerifier::class.java)
63+
LinChecker.check(ByteChannelLinearizabilityTest::class.java, options)
5864
}
5965
}

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/WriteBlockLinearizabilityTest.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import com.devexperts.dxlab.lincheck.stress.*
66
import kotlinx.coroutines.experimental.*
77
import org.junit.*
88

9-
@StressCTest(iterations = 200, invocationsPerIteration = 2_000, actorsPerThread = arrayOf("1:1", "1:1"), verifier = LinVerifier::class)
109
@OpGroupConfigs(
1110
OpGroupConfig(name = "write", nonParallel = true),
1211
OpGroupConfig(name = "read", nonParallel = true)
1312
)
14-
class WriteBlockLinearizabilityTest {
13+
class WriteBlockLinearizabilityTest : TestBase() {
1514
private lateinit var ch: ByteChannel
1615

1716
private val lr = LinTesting()
@@ -38,6 +37,12 @@ class WriteBlockLinearizabilityTest {
3837

3938
@Test
4039
fun test() {
41-
LinChecker.check(WriteBlockLinearizabilityTest::class.java)
40+
val options = StressOptions()
41+
.iterations(100)
42+
.invocationsPerIteration(1000 * stressTestMultiplier)
43+
.addThread(1, 1)
44+
.addThread(1, 1)
45+
.verifier(LinVerifier::class.java)
46+
LinChecker.check(WriteBlockLinearizabilityTest::class.java, options)
4247
}
4348
}

0 commit comments

Comments
 (0)