Skip to content

Commit 5e1faf7

Browse files
committed
enable all transport tests, remove delays, cleanup code
1 parent c6e36b4 commit 5e1faf7

File tree

1 file changed

+56
-46
lines changed
  • rsocket-transport-tests/src/commonMain/kotlin/io/rsocket/kotlin/transport/tests

1 file changed

+56
-46
lines changed

Diff for: rsocket-transport-tests/src/commonMain/kotlin/io/rsocket/kotlin/transport/tests/TransportTest.kt

+56-46
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,25 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck {
6060
@Test
6161
fun fireAndForget10() = test {
6262
(1..10).map { async { client.fireAndForget(payload(it)) } }.awaitAll()
63-
delay(1000) //TODO: leak check
63+
// delay(1000) //TODO: leak check
6464
}
6565

6666
@Test
6767
open fun largePayloadFireAndForget10() = test {
6868
(1..10).map { async { client.fireAndForget(requesterLargePayload) } }.awaitAll()
69-
delay(1000) //TODO: leak check
69+
// delay(1000) //TODO: leak check
7070
}
7171

7272
@Test
7373
fun metadataPush10() = test {
7474
(1..10).map { async { client.metadataPush(packet(requesterData)) } }.awaitAll()
75-
delay(1000) //TODO: leak check
75+
// delay(1000) //TODO: leak check
7676
}
7777

7878
@Test
7979
open fun largePayloadMetadataPush10() = test {
8080
(1..10).map { async { client.metadataPush(packet(requesterLargeData)) } }.awaitAll()
81-
delay(1000) //TODO: leak check
81+
// delay(1000) //TODO: leak check
8282
}
8383

8484
@Test
@@ -89,106 +89,116 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck {
8989

9090
@Test
9191
fun requestChannel1() = test(10.seconds) {
92-
val list = client.requestChannel(payload(0), flowOf(payload(0))).onEach { it.close() }.toList()
93-
assertEquals(1, list.size)
92+
val count =
93+
client.requestChannel(payload(0), flowOf(payload(0)))
94+
.onEach { it.close() }
95+
.count()
96+
assertEquals(1, count)
9497
}
9598

9699
@Test
97100
fun requestChannel3() = test {
98101
val request = flow {
99102
repeat(3) { emit(payload(it)) }
100103
}
101-
val list =
102-
client.requestChannel(payload(0), request).flowOn(PrefetchStrategy(3, 0)).onEach { it.close() }.toList()
103-
assertEquals(3, list.size)
104+
val count =
105+
client.requestChannel(payload(0), request)
106+
.flowOn(PrefetchStrategy(3, 0))
107+
.onEach { it.close() }
108+
.count()
109+
assertEquals(3, count)
104110
}
105111

106112
@Test
107113
open fun largePayloadRequestChannel200() = test {
108114
val request = flow {
109115
repeat(200) { emit(requesterLargePayload) }
110116
}
111-
val list =
117+
val count =
112118
client.requestChannel(requesterLargePayload, request)
113119
.flowOn(PrefetchStrategy(Int.MAX_VALUE, 0))
114120
.onEach { it.close() }
115-
.toList()
116-
assertEquals(200, list.size)
121+
.count()
122+
assertEquals(200, count)
117123
}
118124

119125
@Test
120-
@Ignore //flaky, ignore for now
126+
//@Ignore //flaky, ignore for now
121127
fun requestChannel20000() = test {
122128
val request = flow {
123129
repeat(20_000) { emit(payload(7)) }
124130
}
125-
val list = client.requestChannel(payload(7), request).flowOn(PrefetchStrategy(Int.MAX_VALUE, 0)).onEach {
131+
val count = client.requestChannel(payload(7), request).flowOn(PrefetchStrategy(Int.MAX_VALUE, 0)).onEach {
126132
assertEquals(requesterData, it.data.readText())
127133
assertEquals(requesterMetadata, it.metadata?.readText())
128-
}.toList()
129-
assertEquals(20_000, list.size)
134+
}.count()
135+
assertEquals(20_000, count)
130136
}
131137

132138
@Test
133-
@Ignore //flaky, ignore for now
139+
//@Ignore //flaky, ignore for now
134140
fun requestChannel200000() = test {
135141
val request = flow {
136142
repeat(200_000) { emit(payload(it)) }
137143
}
138-
val list =
139-
client.requestChannel(payload(0), request).flowOn(PrefetchStrategy(10000, 0)).onEach { it.close() }.toList()
140-
assertEquals(200_000, list.size)
144+
val count =
145+
client.requestChannel(payload(0), request)
146+
.flowOn(PrefetchStrategy(10000, 0))
147+
.onEach { it.close() }
148+
.count()
149+
assertEquals(200_000, count)
141150
}
142151

143152
@Test
144-
@Ignore //flaky, ignore for now
153+
//@Ignore //flaky, ignore for now
145154
fun requestChannel16x256() = test {
146155
val request = flow {
147156
repeat(256) {
148157
emit(payload(it))
149158
}
150159
}
151-
(0..16).map {
152-
async(Dispatchers.Default) {
153-
val list = client.requestChannel(payload(0), request).onEach { it.close() }.toList()
154-
assertEquals(256, list.size)
160+
(0..16).map { r ->
161+
async {
162+
val count = client.requestChannel(payload(0), request).onEach { it.close() }.count()
163+
assertEquals(256, count)
155164
}
156165
}.awaitAll()
157166
}
158167

159168
@Test
160-
@Ignore //flaky, ignore for now
169+
//@Ignore //flaky, ignore for now
161170
fun requestChannel256x512() = test {
162171
val request = flow {
163172
repeat(512) {
164173
emit(payload(it))
165174
}
166175
}
167176
(0..256).map {
168-
async(Dispatchers.Default) {
169-
val list = client.requestChannel(payload(0), request).onEach { it.close() }.toList()
170-
assertEquals(512, list.size)
177+
async {
178+
val count = client.requestChannel(payload(0), request).onEach { it.close() }.count()
179+
assertEquals(512, count)
171180
}
172181
}.awaitAll()
173182
}
174183

175184
@Test
176-
@Ignore //flaky, ignore for now
185+
//@Ignore //flaky, ignore for now
177186
fun requestChannel500NoLeak() = test {
178187
val request = flow {
179188
repeat(10_000) { emitOrClose(payload(3)) }
180189
}
181-
val list =
190+
val count =
182191
client
183192
.requestChannel(payload(3), request)
184193
.flowOn(PrefetchStrategy(Int.MAX_VALUE, 0))
185194
.take(500)
186195
.onEach {
187196
assertEquals(requesterData, it.data.readText())
188197
assertEquals(requesterMetadata, it.metadata?.readText())
189-
}.toList()
190-
assertEquals(500, list.size)
191-
delay(1000) //TODO: leak check
198+
}
199+
.count()
200+
assertEquals(500, count)
201+
//(1000) //TODO: leak check
192202
}
193203

194204
@Test
@@ -212,42 +222,42 @@ abstract class TransportTest : SuspendTest, TestWithLeakCheck {
212222
}
213223

214224
@Test
215-
@Ignore //flaky, ignore for now
225+
//@Ignore //flaky, ignore for now
216226
fun requestResponse10000() = test {
217227
(1..10000).map { async { client.requestResponse(payload(3)).let(Companion::checkPayload) } }.awaitAll()
218228
}
219229

220230
@Test
221-
@Ignore //flaky, ignore for now
231+
//@Ignore //flaky, ignore for now
222232
fun requestResponse100000() = test {
223233
repeat(100000) { client.requestResponse(payload(3)).let(Companion::checkPayload) }
224234
}
225235

226236
@Test
227237
fun requestStream5() = test {
228-
val list =
229-
client.requestStream(payload(3)).flowOn(PrefetchStrategy(5, 0)).take(5).onEach { checkPayload(it) }.toList()
230-
assertEquals(5, list.size)
238+
val count =
239+
client.requestStream(payload(3)).flowOn(PrefetchStrategy(5, 0)).take(5).onEach { checkPayload(it) }.count()
240+
assertEquals(5, count)
231241
}
232242

233243
@Test
234244
fun requestStream10000() = test {
235-
val list = client.requestStream(payload(3)).onEach { checkPayload(it) }.toList()
236-
assertEquals(10000, list.size)
245+
val count = client.requestStream(payload(3)).onEach { checkPayload(it) }.count()
246+
assertEquals(10000, count)
237247
}
238248

239249
@Test
240-
@Ignore //flaky, ignore for now
250+
//@Ignore //flaky, ignore for now
241251
fun requestStream500NoLeak() = test {
242-
val list =
252+
val count =
243253
client
244254
.requestStream(payload(3))
245255
.flowOn(PrefetchStrategy(Int.MAX_VALUE, 0))
246256
.take(500)
247257
.onEach { checkPayload(it) }
248-
.toList()
249-
assertEquals(500, list.size)
250-
delay(1000) //TODO: leak check
258+
.count()
259+
assertEquals(500, count)
260+
// delay(1000) //TODO: leak check
251261
}
252262

253263
companion object {

0 commit comments

Comments
 (0)