How can I test back-pressure?
See original GitHub issueHi, I was wondering if there is any mechanism to test the same back-pressure behavior that collect()
has.
Here is an example on the different behaviors I encounter.
@Test
public fun `when I test - flow should backpressure`(): TestResult = runTest {
val myFlow:Flow<Int> = flow {
println("emitting 1")
emit(1)
println("emitted 1")
delay(10)
println("emitting 2")
emit(2)
println("emitted 2")
delay(10)
println("emitting 3")
emit(3)
println("emitted 3")
}
println("COLLECT")
myFlow.collect {
println("collected $it")
delay(50)
}
println()
println("TEST")
// Test
myFlow.test {
val item1 = awaitItem()
println("collected $item1")
delay(50)
val item2 = awaitItem()
println("collected $item2")
delay(50)
val item3 = awaitItem()
println("collected $item3")
awaitComplete()
}
}
Prints
COLLECT
emitting 1
collected 1
emitted 1
emitting 2
collected 2
emitted 2
emitting 3
collected 3
emitted 3
TEST
emitting 1
emitted 1
emitting 2
emitted 2
emitting 3
emitted 3
collected 1
collected 2
collected 3
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Exhaust Back Pressure Test - Direct & Temperature - YouTube
In this video, I will guide you how to troubleshoot the exhaust back pressure. You should make sure, the back pressure is not...
Read more >Simple Diagnostic Testing - Walker Exhaust
These tests are used to determine if blockages exist in the exhaust system, creating excessive backpressure. The following tests can help determine the...
Read more >BPT02 Back Pressure Test Kit Instructions - Hickok Inc.
Using the BPT02 Back Pressure Test Kit will provide you with the most accurate and reliable means for detecting a restricted exhaust system....
Read more >What is Backpressure testing of PRV? - AMARINE
The Backpressure Test is a compressed air or gas at a pressure of at least 2 bars. Go from the outlet side of...
Read more >Exhaust Backpressure Testing (known bad compared to ...
Tools used · exhaust back-pressure test kit · vacuum/pressure gauge ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We can possibly design a variation of the API that allows applying backpressure by using a channel with a smaller buffer and potentially an intermediate coroutine which controls the number of allowed items before it blocks the collector.
I mean we can omit it and start with only two modes: rendezvous or unlimited buffer. If someone complains at least we have an idea on how to build support for arbitrary buffer capacities, but maybe no one actually needs it.