Skip to content

Commit

Permalink
Improve Travis build integration
Browse files Browse the repository at this point in the history
 - modify cache configuration could lead to small speedup
 - remove the jvmIfFatal test from FluxTests (more detailed assertions
   have instead been added in a test in SchedulersTest)
 - remove some tests compilation warnings
 - fix param javadoc warnings
 - output 1 line per test (passed or failed) so that
   it is less likely that a Travis build is killed for log inactivity
   (and if it is we know which last test was launched) while also
   getting failure details
  • Loading branch information
simonbasle committed Dec 15, 2016
1 parent 39a707a commit 1274a8a
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 43 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ sudo: required
after_success:
- bash <(curl -s https://codecov.io/bash)

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.m2
- $HOME/.gradle
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ configure(rootProject) {

sourceSets.test.resources.srcDirs = ["src/test/resources", "src/test/java"]

test {
testLogging {
events "passed", "failed"
showExceptions true
exceptionFormat "full"
maxGranularity 3
}
}

if (!JavaVersion.current().isJava9Compatible()) {
test {
jvmArgs = ["-Xbootclasspath/p:" + configurations.jsr166backport.asPath]
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/reactor/core/publisher/Mono.java
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ public final <T2, O> Mono<O> and(Mono<? extends T2> other, BiFunction<?

/**
* Wait for the result from this mono, use it to create a second mono via the
* provided {@param rightGenerator} function and combine both results into a {@link Tuple2}.
* provided {@code rightGenerator} function and combine both results into a {@link Tuple2}.
*
* <p>
* <img class="marble" src="https://raw.githubusercontent.com/reactor/projectreactor.io/master/src/main/static/assets/img/marble/and.png" alt="">
Expand All @@ -1121,8 +1121,8 @@ public final <T2> Mono<Tuple2<T, T2>> and(Function<T, Mono<? extends T2>> rightG

/**
* Wait for the result from this mono, use it to create a second mono via the
* provided {@param rightGenerator} function and combine both results into an arbitrary
* {@code O} object, as defined by the provided {@param combinator} function.
* provided {@code rightGenerator} function and combine both results into an arbitrary
* {@code O} object, as defined by the provided {@code combinator} function.
*
* <p>
* <img class="marble" src="https://raw.githubusercontent.com/reactor/projectreactor.io/master/src/main/static/assets/img/marble/and.png" alt="">
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/reactor/core/publisher/MonoPublishOnTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ public void rejectedExecutionExceptionOnErrorSignalExecutorService()
}

@Test
public void rejectedExecutionSubsribeExecutorScheduler() {
public void rejectedExecutionSubscribeExecutorScheduler() {
CountDownLatch latch = new CountDownLatch(1);
ExecutorService executor = new ThreadPoolExecutor(1,
1,
0L,
MILLISECONDS,
new SynchronousQueue(),
new SynchronousQueue<>(),
new AbortPolicy());

try {
Expand Down Expand Up @@ -310,7 +310,7 @@ public void rejectedExecutionSubsribeExecutorServiceScheduler() {
1,
0L,
MILLISECONDS,
new SynchronousQueue(),
new SynchronousQueue<>(),
new AbortPolicy());

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public void testEmitter() throws Throwable {
Scheduler c = Schedulers.single();
for (int i = 0; i < subs; i++) {
processor.publishOn(c)
.subscribe(d -> latch.countDown(), null, latch::countDown, 1);
.limitRate(1)
.subscribe(d -> latch.countDown(), null, latch::countDown);
}

BlockingSink<Integer> session = processor.connectSink();
Expand Down
29 changes: 0 additions & 29 deletions src/test/java/reactor/core/publisher/scenarios/FluxTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1588,35 +1588,6 @@ public void testThrowWithoutOnErrorShowsUpInSchedulerHandler() {
}
}

@Test
public void testJvmFatalDoesntShowUpInSchedulerHandler() {
AtomicReference<String> failure = new AtomicReference<>(null);

Thread.setDefaultUncaughtExceptionHandler((t, e) -> failure.set("unexpected call to default" +
" UncaughtExceptionHandler with " + e));
Schedulers.onHandleError((t, e) -> failure.set("Fatal JVM error was unexpectedly handled"));

CountDownLatch latch = new CountDownLatch(1);
try {
Flux.intervalMillis(100)
.take(1)
.publishOn(Schedulers.parallel())
.doOnTerminate(() -> latch.countDown())
.subscribe(i -> {
throw new ThreadDeath();
});
latch.await(1, TimeUnit.SECONDS);
} catch (Throwable e) {
fail(e.toString());
} finally {
Thread.setDefaultUncaughtExceptionHandler(null);
Schedulers.resetOnHandleError();
}
if (failure.get() != null) {
fail(failure.get());
}
}

@Test
@Ignore
public void splitBugEventuallyHappens() throws Exception {
Expand Down
37 changes: 31 additions & 6 deletions src/test/java/reactor/core/scheduler/SchedulersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.junit.Test;
import reactor.core.Exceptions;

import static org.junit.Assert.fail;

public class SchedulersTest {

final static class TestSchedulers implements Schedulers.Factory {
Expand Down Expand Up @@ -95,15 +97,15 @@ public void testShutdownOldOnSetFactory() {
Schedulers.Factory ts1 = new Schedulers.Factory() { };
Schedulers.Factory ts2 = new TestSchedulers(false);
Schedulers.setFactory(ts1);
TimedScheduler cachedTimerOld = ((Supplier<TimedScheduler>) Schedulers.timer()).get();
TimedScheduler cachedTimerOld = uncache(Schedulers.timer());
TimedScheduler standaloneTimer = Schedulers.newTimer("standaloneTimer");

Assert.assertNotEquals(cachedTimerOld, standaloneTimer);
Assert.assertNotEquals(cachedTimerOld.schedule(() -> {}), Scheduler.REJECTED);
Assert.assertNotEquals(standaloneTimer.schedule(() -> {}), Scheduler.REJECTED);

Schedulers.setFactory(ts2);
TimedScheduler cachedTimerNew = ((Supplier<TimedScheduler>) Schedulers.timer()).get();
TimedScheduler cachedTimerNew = uncache(Schedulers.timer());

Assert.assertEquals(cachedTimerNew, Schedulers.newTimer("unused"));
Assert.assertNotEquals(cachedTimerNew, cachedTimerOld);
Expand All @@ -115,6 +117,14 @@ public void testShutdownOldOnSetFactory() {
Assert.assertNotEquals(cachedTimerNew.schedule(() -> {}), Scheduler.REJECTED);
}

@SuppressWarnings("unchecked")
private <T extends Scheduler> T uncache(T scheduler) {
if (scheduler instanceof Supplier) {
return ((Supplier<T>) scheduler).get();
}
throw new IllegalArgumentException("not a cache scheduler, expected Supplier<? extends Scheduler>");
}

@Test
public void testUncaughtHookCalledWhenOnErrorNotImplemented() {
AtomicBoolean handled = new AtomicBoolean(false);
Expand All @@ -141,17 +151,32 @@ public void testUncaughtHookCalledWhenCommonException() {
Assert.assertTrue("IllegalArgumentException not handled", handled.get());
}

@Test(expected = ThreadDeath.class)
@Test
public void testUncaughtHookNotCalledWhenThreadDeath() {
AtomicBoolean handled = new AtomicBoolean(false);
Schedulers.onHandleError((t, e) -> handled.set(true));
AtomicReference<String> failure = new AtomicReference<>(null);
Thread.setDefaultUncaughtExceptionHandler((t, e) -> failure.set("unexpected call to default" +
" UncaughtExceptionHandler from " + t.getName() + ": " + e));
Schedulers.onHandleError((t, e) -> {
handled.set(true);
failure.set("Fatal JVM error was unexpectedly handled in " + t.getName() + ": " + e);
});
ThreadDeath fatal = new ThreadDeath();

try {
Schedulers.handleError(new ThreadDeath());
} finally {
Schedulers.handleError(fatal);
fail("expected fatal ThreadDeath exception");
}
catch (ThreadDeath e) {
Assert.assertSame(e, fatal);
}
finally {
Schedulers.resetOnHandleError();
}
Assert.assertFalse("threadDeath not silenced", handled.get());
if (failure.get() != null) {
fail(failure.get());
}
}

//private final int BUFFER_SIZE = 8;
Expand Down

0 comments on commit 1274a8a

Please sign in to comment.