reactive-streams/reactive-streams-jvm

TCK: Receptacle#expectError timeout approach

Scottmitch opened this issue · 1 comments

defaultTimeoutMillis is typically used as a "max time to wait until an expected event occurs". For example this value is used as the argument to a ArrayBlockingQueue#poll(timeout) [1][2][3] method call and therefore when things work as expected you rarely wait this full duration. However Receptacle#expectError does a Thread.sleep(..) and then checks if there is something present in the error list (which is a CopyOnWriteArrayList). The value for the sleep is typically derived from defaultTimeoutMillis which leads to unconditional delays. This makes it challenging to use defaultTimeoutMillis in tests to specify "maximum amount of time to wait until some event occurs". The impacts are if defaultTimeoutMillis is set very small you are more likely to see timeouts (especially on over utilized CI servers), but if is large defaultTimeoutMillis the tests take a long time to complete.

[1] https://github.com/reactive-streams/reactive-streams-jvm/blob/master/tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java#L1019
[2] https://github.com/reactive-streams/reactive-streams-jvm/blob/master/tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java#L978
[3] https://github.com/reactive-streams/reactive-streams-jvm/blob/master/tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java#L990

PR #452 submitted to address this issue.