Netflix/Hystrix — pull request #294 by ahus1 (2014-08-09 16:41:52+00:00)
Title: Stabilize randomly failing tests

Hello Hystrix team,

I found that some tests in HystrixObservableCommandTest have been failing randomly on my machine (gradle and IDE) and also on the CI server. This also happend on my other pull request #293 and I believe #282 has the same reason.

The reason I found for this is a congestion in the RxJava Schedulers.computation() queue: RxJava starts as many threads as the machine has cores (on my machine that's four). Especially HystrixObservableCommandTest.TestCommandWithTimeout that avoids any interruptions will still run after a test. The leftover Observables will delay the Observables in the following test and will lead to a timeout and a randomly failing test.

I stabilized the tests for me (running both IDE and gradle) by a code snippet that drains the Schedulers.computation() queue after each test.

An alternative would have been to switch from Schedulers.computation() to Schedulers.io() that isn't limited in the number of threads. But I am not familiar enough with the code to switch all .computation() to .io() in HystrixObservableCommandTest.

Please let me know if you prefer this solution or another. Solving the congestion in RxJava is important to stabilize the tests.

Thanks,
Alexander.