Skip to content

Commit 8e92534

Browse files
authored
1.x: increase timeout of some tests (#5471)
* 1.x: increase timeout of some tests * OperatorFlatMapTest.flatMapRangeMixedAsyncLoop more time * Retry testNoBufferingOrBlockingOfSequence multiple times
1 parent b8f3ced commit 8e92534

File tree

7 files changed

+69
-58
lines changed

7 files changed

+69
-58
lines changed

src/main/java/rx/SingleEmitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* <p>
2424
* All methods are thread-safe; calling onSuccess or onError twice or one after the other has
2525
* no effect.
26-
* <p>History: 1.2.3 - experimental
26+
* <p>History: 1.2.3 - experimental
2727
* @param <T> the success value type
2828
* @since 1.3
2929
*/

src/main/java/rx/observables/AsyncOnSubscribe.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ boolean tryEmit(long n) {
532532
onNextCalled = false;
533533
expectedDelivery = n;
534534
nextIteration(n);
535-
536-
//hasTerminated will be true when onCompleted was already emitted from the request callback
537-
//even if the the observer has not seen onCompleted from the requested observable,
535+
536+
//hasTerminated will be true when onCompleted was already emitted from the request callback
537+
//even if the the observer has not seen onCompleted from the requested observable,
538538
//so we should not clean up while there are active subscriptions
539539
if (hasTerminated && !subscriptions.hasSubscriptions() || isUnsubscribed()) {
540540
cleanup();

src/test/java/rx/internal/operators/BlockingOperatorNextTest.java

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -234,69 +234,80 @@ public void testNextWithCallingHasNextMultipleTimes() {
234234
*/
235235
@Test
236236
public void testNoBufferingOrBlockingOfSequence() throws Throwable {
237-
final CountDownLatch finished = new CountDownLatch(1);
238-
final int COUNT = 30;
239-
final CountDownLatch timeHasPassed = new CountDownLatch(COUNT);
240-
final AtomicBoolean running = new AtomicBoolean(true);
241-
final AtomicInteger count = new AtomicInteger(0);
242-
final Observable<Integer> obs = Observable.unsafeCreate(new Observable.OnSubscribe<Integer>() {
237+
int retries = 10;
243238

244-
@Override
245-
public void call(final Subscriber<? super Integer> o) {
246-
new Thread(new Runnable() {
239+
for (;;) {
240+
try {
241+
final CountDownLatch finished = new CountDownLatch(1);
242+
final int COUNT = 30;
243+
final CountDownLatch timeHasPassed = new CountDownLatch(COUNT);
244+
final AtomicBoolean running = new AtomicBoolean(true);
245+
final AtomicInteger count = new AtomicInteger(0);
246+
final Observable<Integer> obs = Observable.unsafeCreate(new Observable.OnSubscribe<Integer>() {
247247

248248
@Override
249-
public void run() {
250-
try {
251-
while (running.get()) {
252-
o.onNext(count.incrementAndGet());
253-
timeHasPassed.countDown();
249+
public void call(final Subscriber<? super Integer> o) {
250+
new Thread(new Runnable() {
251+
252+
@Override
253+
public void run() {
254+
try {
255+
while (running.get()) {
256+
o.onNext(count.incrementAndGet());
257+
timeHasPassed.countDown();
258+
}
259+
o.onCompleted();
260+
} catch (Throwable e) {
261+
o.onError(e);
262+
} finally {
263+
finished.countDown();
264+
}
254265
}
255-
o.onCompleted();
256-
} catch (Throwable e) {
257-
o.onError(e);
258-
} finally {
259-
finished.countDown();
260-
}
266+
}).start();
261267
}
262-
}).start();
263-
}
264268

265-
});
269+
});
266270

267-
try {
268-
Iterator<Integer> it = next(obs).iterator();
271+
try {
272+
Iterator<Integer> it = next(obs).iterator();
269273

270-
assertTrue(it.hasNext());
271-
int a = it.next();
272-
assertTrue(it.hasNext());
273-
int b = it.next();
274-
// we should have a different value
275-
assertTrue("a and b should be different", a != b);
274+
assertTrue(it.hasNext());
275+
int a = it.next();
276+
assertTrue(it.hasNext());
277+
int b = it.next();
278+
// we should have a different value
279+
assertTrue("a and b should be different", a != b);
276280

277-
// wait for some time (if times out we are blocked somewhere so fail ... set very high for very slow, constrained machines)
278-
timeHasPassed.await(8000, TimeUnit.MILLISECONDS);
281+
// wait for some time (if times out we are blocked somewhere so fail ... set very high for very slow, constrained machines)
282+
timeHasPassed.await(8000, TimeUnit.MILLISECONDS);
279283

280-
assertTrue(it.hasNext());
281-
int c = it.next();
284+
assertTrue(it.hasNext());
285+
int c = it.next();
282286

283-
assertTrue("c should not just be the next in sequence", c != (b + 1));
284-
assertTrue("expected that c [" + c + "] is higher than or equal to " + COUNT, c >= COUNT);
287+
assertTrue("c should not just be the next in sequence", c != (b + 1));
288+
assertTrue("expected that c [" + c + "] is higher than or equal to " + COUNT, c >= COUNT);
285289

286-
assertTrue(it.hasNext());
287-
int d = it.next();
288-
assertTrue(d > c);
290+
assertTrue(it.hasNext());
291+
int d = it.next();
292+
assertTrue(d > c);
289293

290-
// shut down the thread
291-
running.set(false);
294+
// shut down the thread
295+
running.set(false);
292296

293-
finished.await();
297+
finished.await();
294298

295-
assertFalse(it.hasNext());
299+
assertFalse(it.hasNext());
296300

297-
System.out.println("a: " + a + " b: " + b + " c: " + c);
298-
} finally {
299-
running.set(false); // don't let the thread spin indefinitely
301+
System.out.println("a: " + a + " b: " + b + " c: " + c);
302+
} finally {
303+
running.set(false); // don't let the thread spin indefinitely
304+
}
305+
return;
306+
} catch (AssertionError ex) {
307+
if (retries-- == 0) {
308+
throw ex;
309+
}
310+
}
300311
}
301312
}
302313

src/test/java/rx/internal/operators/CompletableOnErrorXTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class CompletableOnErrorXTest {
2929
@Test
3030
public void nextUnsubscribe() {
3131
PublishSubject<Integer> ps = PublishSubject.create();
32-
32+
3333
AssertableSubscriber<Void> as = ps.toCompletable()
3434
.onErrorResumeNext(new Func1<Throwable, Completable>() {
3535
@Override
@@ -49,7 +49,7 @@ public Completable call(Throwable e) {
4949
@Test
5050
public void completeUnsubscribe() {
5151
PublishSubject<Integer> ps = PublishSubject.create();
52-
52+
5353
AssertableSubscriber<Void> as = ps.toCompletable()
5454
.onErrorComplete()
5555
.test();

src/test/java/rx/internal/operators/OperatorFlatMapTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public Observable<Integer> call(Integer t) {
468468
}
469469
}
470470
}
471-
@Test(timeout = 30000)
471+
@Test(timeout = 60000)
472472
public void flatMapRangeMixedAsyncLoop() {
473473
for (int i = 0; i < 2000; i++) {
474474
if (i % 10 == 0) {

src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public void testSimpleAsyncLoop() {
197197
testSimpleAsync();
198198
}
199199
}
200-
@Test(timeout = 10000)
200+
@Test(timeout = 30000)
201201
public void testSimpleAsync() {
202202
for (int i = 1; i < 50; i++) {
203203
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
@@ -217,7 +217,7 @@ public void testSimpleAsync() {
217217
assertEquals(expected, actual);
218218
}
219219
}
220-
@Test(timeout = 10000)
220+
@Test(timeout = 30000)
221221
public void testSimpleOneLessAsyncLoop() {
222222
int max = 200;
223223
if (PlatformDependent.isAndroid()) {
@@ -227,7 +227,7 @@ public void testSimpleOneLessAsyncLoop() {
227227
testSimpleOneLessAsync();
228228
}
229229
}
230-
@Test(timeout = 10000)
230+
@Test(timeout = 30000)
231231
public void testSimpleOneLessAsync() {
232232
long t = System.currentTimeMillis();
233233
for (int i = 2; i < 50; i++) {

src/test/java/rx/internal/operators/OperatorSwitchTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ public void asyncInner() throws Throwable {
894894
.switchMap(UtilityFunctions.<Observable<Integer>>identity())
895895
.observeOn(Schedulers.computation())
896896
.ignoreElements()
897-
.timeout(5, TimeUnit.SECONDS)
897+
.timeout(15, TimeUnit.SECONDS)
898898
.toBlocking()
899899
.subscribe(Actions.empty(), new Action1<Throwable>() {
900900
@Override

0 commit comments

Comments
 (0)