@Test(timeout = 30000)
public void flatMapRangeMixedAsyncLoop() {

    for (int i = 0; i < 2000; i++) {
        if (i % 10 == 0) {
            System.out.println("flatMapRangeAsyncLoop > " + i);
        }
        TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
        Flowable.range(0, 1000)
        .flatMap(new Function<Integer, Flowable<Integer>>() {
            final Random rnd = new Random();
            @Override
            public Flowable<Integer> apply(Integer t) {
                Flowable<Integer> r = Flowable.just(t);
                if (rnd.nextBoolean()) {
                    r = r.hide();
                }
                return r;
            }
        })
        .observeOn(Schedulers.computation())
        .subscribe(ts);
        ts.awaitTerminalEvent(2500, TimeUnit.MILLISECONDS);
        if (ts.completions() == 0) {
            System.out.println(ts.valueCount());
        }
        ts.assertTerminated();
        ts.assertNoErrors();
        List<Integer> list = ts.values();
        if (list.size() < 1000) {
            Set<Integer> set = new HashSet<Integer>(list);
            for (int j = 0; j < 1000; j++) {
                if (!set.contains(j)) {
                    System.out.println(j + " missing");
                }
            }
        }
        assertEquals(1000, list.size());
    }
}