Skip to content

Commit 9bf94d4

Browse files
committed
Fix TravisCI build
Due to exceeding the 50 minute time limit, the support team was very kind by extending it to 90 minutes. For now, merging this slow tests into the same job for a fuller code coverage report. Moving to a VM instance (vs container) for a beefer machine. This had hung because some Guava tests block indefinitely on CountDownLatches. Since I had switched their tests to use a pool instead of new threads, thread starvation meant no progress could be made. Reverted to ad hoc threads and added a timeout to the awaits().
1 parent 05e7f64 commit 9bf94d4

File tree

9 files changed

+62
-64
lines changed

9 files changed

+62
-64
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: java
2-
sudo: false
2+
sudo: required
33

44
jdk:
55
- oraclejdk8
@@ -9,8 +9,7 @@ env:
99
- TERM=dumb
1010
matrix:
1111
- GROUP=analysis
12-
- GROUP=unitTests
13-
- GROUP=slowTests
12+
- GROUP=tests
1413

1514
before_install:
1615
- cp gradle.properties.ci gradle.properties

caffeine/src/test/java/com/github/benmanes/caffeine/cache/AsyncTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import java.lang.reflect.Constructor;
3030
import java.util.concurrent.CompletableFuture;
31-
import java.util.concurrent.ForkJoinPool;
3231
import java.util.concurrent.TimeUnit;
3332
import java.util.concurrent.atomic.AtomicInteger;
3433

@@ -38,6 +37,7 @@
3837

3938
import com.github.benmanes.caffeine.cache.Async.AsyncExpiry;
4039
import com.github.benmanes.caffeine.testing.Awaits;
40+
import com.github.benmanes.caffeine.testing.ConcurrentTestHarness;
4141

4242
/**
4343
* @author [email protected] (Ben Manes)
@@ -81,7 +81,7 @@ public void getWhenSuccessful_success(CompletableFuture<?> future) {
8181
public void getWhenSuccessful_success_async() {
8282
CompletableFuture<Integer> future = new CompletableFuture<Integer>();
8383
AtomicInteger result = new AtomicInteger();
84-
ForkJoinPool.commonPool().execute(() -> {
84+
ConcurrentTestHarness.execute(() -> {
8585
result.set(1);
8686
result.set(Async.getWhenSuccessful(future));
8787
});
@@ -94,7 +94,7 @@ public void getWhenSuccessful_success_async() {
9494
public void getWhenSuccessful_fails(CompletableFuture<?> future) {
9595
if ((future != null) && !future.isDone()) {
9696
AtomicInteger result = new AtomicInteger();
97-
ForkJoinPool.commonPool().execute(() -> {
97+
ConcurrentTestHarness.execute(() -> {
9898
result.set(1);
9999
Object value = Async.getWhenSuccessful(future);
100100
result.set((value == null) ? 2 : 3);

gradle.properties.ci

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
org.gradle.jvmargs=-Xmx384m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -noverify
2-
org.gradle.daemon=false
1+
org.gradle.jvmargs=-Xmx1024m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -noverify
2+
org.gradle.daemon=true
33
nexusUsername=
44
nexusPassword=

gradle/dependencies.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ext {
6262
ehcache3: '3.3.1',
6363
elasticSearch: '5.4.0',
6464
expiringMap: '0.5.8',
65-
jackrabbit: '1.7.2',
65+
jackrabbit: '1.7.3',
6666
jamm: '0.3.1',
6767
javaObjectLayout: '0.8',
6868
jmh: 1.19,
@@ -73,17 +73,17 @@ ext {
7373
tcache: '1.0.3',
7474
]
7575
pluginVersions = [
76-
buildscan: '1.7.4',
76+
buildscan: '1.8',
7777
buildscanRecipes: '0.2.0',
7878
checkstyle: '8.0',
7979
coveralls: '2.8.1',
8080
coverity: '1.0.10',
8181
errorProne: '0.0.10',
8282
jacoco: '0.7.9',
8383
jmh: '0.4.2',
84-
jmhReport: '0.2.0',
84+
jmhReport: '0.4.1',
8585
nexus: '2.3.1',
86-
pmd: '5.8.0',
86+
pmd: '5.8.1',
8787
propdeps: '0.0.10.RELEASE',
8888
semanticVersioning: '1.1.0',
8989
shadow: '2.0.1',

guava/src/test/java/com/google/common/cache/CacheBuilderTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.concurrent.CountDownLatch;
3333
import java.util.concurrent.ExecutorService;
3434
import java.util.concurrent.Executors;
35-
import java.util.concurrent.ForkJoinPool;
3635
import java.util.concurrent.TimeUnit;
3736
import java.util.concurrent.atomic.AtomicBoolean;
3837
import java.util.concurrent.atomic.AtomicInteger;
@@ -329,7 +328,6 @@ public void testNullCache() {
329328
}
330329

331330
@GwtIncompatible("QueuingRemovalListener")
332-
333331
public void testRemovalNotification_clear() throws InterruptedException {
334332
// If a clear() happens while a computation is pending, we should not get a removal
335333
// notification.
@@ -339,7 +337,7 @@ public void testRemovalNotification_clear() throws InterruptedException {
339337
CacheLoader<String, String> computingFunction = new CacheLoader<String, String>() {
340338
@Override public String load(String key) {
341339
if (shouldWait.get()) {
342-
Uninterruptibles.awaitUninterruptibly(computingLatch);
340+
assertTrue(Uninterruptibles.awaitUninterruptibly(computingLatch, 300, TimeUnit.MINUTES));
343341
}
344342
return key;
345343
}
@@ -356,19 +354,19 @@ public void testRemovalNotification_clear() throws InterruptedException {
356354

357355
final CountDownLatch computationStarted = new CountDownLatch(1);
358356
final CountDownLatch computationComplete = new CountDownLatch(1);
359-
ForkJoinPool.commonPool().execute(() -> {
357+
new Thread(() -> {
360358
computationStarted.countDown();
361359
cache.getUnchecked("b");
362360
computationComplete.countDown();
363-
});
361+
}).start();
364362

365363
// wait for the computingEntry to be created
366-
computationStarted.await();
364+
assertTrue(computationStarted.await(300, TimeUnit.MINUTES));
367365
cache.invalidateAll();
368366
// let the computation proceed
369367
computingLatch.countDown();
370368
// don't check cache.size() until we know the get("b") call is complete
371-
computationComplete.await();
369+
assertTrue(computationComplete.await(300, TimeUnit.MINUTES));
372370

373371
// At this point, the listener should be holding the seed value (a -> a), and the map should
374372
// contain the computed value (b -> b), since the clear() happened before the computation
@@ -439,7 +437,7 @@ public void testRemovalNotification_clear_basher() throws InterruptedException {
439437
Thread.yield();
440438
}
441439
cache.invalidateAll();
442-
tasksFinished.await();
440+
assertTrue(tasksFinished.await(300, TimeUnit.MINUTES));
443441

444442
// Check all of the removal notifications we received: they should have had correctly-associated
445443
// keys and values. (An earlier bug saw removal notifications for in-progress computations,
@@ -525,7 +523,7 @@ public void testRemovalNotification_get_basher() throws InterruptedException {
525523
}
526524

527525
threadPool.shutdown();
528-
threadPool.awaitTermination(300, TimeUnit.SECONDS);
526+
assertTrue(threadPool.awaitTermination(300, TimeUnit.SECONDS));
529527

530528
// Since we're not doing any more cache operations, and the cache only expires/evicts when doing
531529
// other operations, the cache and the removal queue won't change from this point on.
@@ -562,7 +560,7 @@ static final class DelayingIdentityLoader<T> extends CacheLoader<T, T> {
562560

563561
@Override public T load(T key) {
564562
if (shouldWait.get()) {
565-
Uninterruptibles.awaitUninterruptibly(delayLatch);
563+
assertTrue(Uninterruptibles.awaitUninterruptibly(delayLatch, 300, TimeUnit.SECONDS));
566564
}
567565
return key;
568566
}

guava/src/test/java/com/google/common/cache/CacheLoadingTest.java

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.concurrent.ConcurrentMap;
3131
import java.util.concurrent.CountDownLatch;
3232
import java.util.concurrent.ExecutionException;
33-
import java.util.concurrent.ForkJoinPool;
3433
import java.util.concurrent.TimeUnit;
3534
import java.util.concurrent.atomic.AtomicBoolean;
3635
import java.util.concurrent.atomic.AtomicInteger;
@@ -1871,7 +1870,7 @@ private static void testConcurrentLoadingDefault(Caffeine<Object, Object> builde
18711870
new CacheLoader<String, Object>() {
18721871
@Override public Object load(String key) {
18731872
callCount.incrementAndGet();
1874-
Uninterruptibles.awaitUninterruptibly(startSignal);
1873+
assertTrue(Uninterruptibles.awaitUninterruptibly(startSignal, 300, TimeUnit.SECONDS));
18751874
return result;
18761875
}
18771876
});
@@ -1900,7 +1899,7 @@ private static void testConcurrentLoadingNull(Caffeine<Object, Object> builder)
19001899
new CacheLoader<String, String>() {
19011900
@Override public String load(String key) {
19021901
callCount.incrementAndGet();
1903-
Uninterruptibles.awaitUninterruptibly(startSignal);
1902+
assertTrue(Uninterruptibles.awaitUninterruptibly(startSignal, 300, TimeUnit.SECONDS));
19041903
return null;
19051904
}
19061905
});
@@ -1938,7 +1937,7 @@ private static void testConcurrentLoadingUncheckedException(
19381937
new CacheLoader<String, String>() {
19391938
@Override public String load(String key) {
19401939
callCount.incrementAndGet();
1941-
Uninterruptibles.awaitUninterruptibly(startSignal);
1940+
assertTrue(Uninterruptibles.awaitUninterruptibly(startSignal, 300, TimeUnit.SECONDS));
19421941
throw e;
19431942
}
19441943
});
@@ -1979,7 +1978,7 @@ private static void testConcurrentLoadingCheckedException(
19791978
new CacheLoader<String, String>() {
19801979
@Override public String load(String key) throws Exception {
19811980
callCount.incrementAndGet();
1982-
Uninterruptibles.awaitUninterruptibly(startSignal);
1981+
assertTrue(Uninterruptibles.awaitUninterruptibly(startSignal, 300, TimeUnit.SECONDS));
19831982
throw e;
19841983
}
19851984
});
@@ -2055,7 +2054,7 @@ private static <K> List<Object> doConcurrentGet(final LoadingCache<K, ?> cache,
20552054
}
20562055
}
20572056
gettersStartedSignal.countDown();
2058-
gettersComplete.await();
2057+
assertTrue(gettersComplete.await(300, TimeUnit.SECONDS));
20592058

20602059
List<Object> resultList = Lists.newArrayListWithExpectedSize(nThreads);
20612060
for (int i = 0; i < nThreads; i++) {
@@ -2076,7 +2075,7 @@ public void testAsMapDuringLoading() throws InterruptedException, ExecutionExcep
20762075
@Override
20772076
public String load(String key) {
20782077
getStartedSignal.countDown();
2079-
Uninterruptibles.awaitUninterruptibly(letGetFinishSignal);
2078+
assertTrue(Uninterruptibles.awaitUninterruptibly(letGetFinishSignal, 300, TimeUnit.SECONDS));
20802079
return key + suffix;
20812080
}
20822081
};
@@ -2090,16 +2089,16 @@ public String load(String key) {
20902089
assertFalse(map.containsKey(getKey));
20912090
assertSame(refreshKey, map.get(refreshKey));
20922091

2093-
ForkJoinPool.commonPool().execute(() -> {
2092+
new Thread(() -> {
20942093
cache.getUnchecked(getKey);
20952094
getFinishedSignal.countDown();
2096-
});
2097-
ForkJoinPool.commonPool().execute(() -> {
2095+
}).start();
2096+
new Thread(() -> {
20982097
cache.refresh(refreshKey);
20992098
getFinishedSignal.countDown();
2100-
});
2099+
}).start();
21012100

2102-
getStartedSignal.await();
2101+
assertTrue(getStartedSignal.await(300, TimeUnit.SECONDS));
21032102

21042103
// computation is in progress; asMap shouldn't have changed
21052104
assertEquals(1, map.size());
@@ -2108,7 +2107,7 @@ public String load(String key) {
21082107

21092108
// let computation complete
21102109
letGetFinishSignal.countDown();
2111-
getFinishedSignal.await();
2110+
assertTrue(getFinishedSignal.await(300, TimeUnit.SECONDS));
21122111
checkNothingLogged();
21132112

21142113
// asMap view should have been updated
@@ -2131,7 +2130,7 @@ public void disabled_testInvalidateDuringLoading() throws InterruptedException,
21312130
@Override
21322131
public String load(String key) {
21332132
computationStarted.countDown();
2134-
Uninterruptibles.awaitUninterruptibly(letGetFinishSignal);
2133+
assertTrue(Uninterruptibles.awaitUninterruptibly(letGetFinishSignal, 300, TimeUnit.SECONDS));
21352134
return key + suffix;
21362135
}
21372136
};
@@ -2141,24 +2140,24 @@ public String load(String key) {
21412140
ConcurrentMap<String,String> map = cache.asMap();
21422141
map.put(refreshKey, refreshKey);
21432142

2144-
ForkJoinPool.commonPool().execute(() -> {
2143+
new Thread(() -> {
21452144
cache.getUnchecked(getKey);
21462145
getFinishedSignal.countDown();
2147-
});
2148-
ForkJoinPool.commonPool().execute(() -> {
2146+
}).start();
2147+
new Thread(() -> {
21492148
cache.refresh(refreshKey);
21502149
getFinishedSignal.countDown();
2151-
});
2150+
}).start();
21522151

2153-
computationStarted.await();
2152+
assertTrue(computationStarted.await(300, TimeUnit.SECONDS));
21542153
cache.invalidate(getKey);
21552154
cache.invalidate(refreshKey);
21562155
assertFalse(map.containsKey(getKey));
21572156
assertFalse(map.containsKey(refreshKey));
21582157

21592158
// let computation complete
21602159
letGetFinishSignal.countDown();
2161-
getFinishedSignal.await();
2160+
assertTrue(getFinishedSignal.await(300, TimeUnit.SECONDS));
21622161
checkNothingLogged();
21632162

21642163
// results should be visible
@@ -2183,7 +2182,7 @@ public void disabled_testInvalidateAndReloadDuringLoading()
21832182
@Override
21842183
public String load(String key) {
21852184
computationStarted.countDown();
2186-
Uninterruptibles.awaitUninterruptibly(letGetFinishSignal);
2185+
assertTrue(Uninterruptibles.awaitUninterruptibly(letGetFinishSignal, 300, TimeUnit.SECONDS));
21872186
return key + suffix;
21882187
}
21892188
};
@@ -2193,34 +2192,34 @@ public String load(String key) {
21932192
ConcurrentMap<String,String> map = cache.asMap();
21942193
map.put(refreshKey, refreshKey);
21952194

2196-
ForkJoinPool.commonPool().execute(() -> {
2195+
new Thread(() -> {
21972196
cache.getUnchecked(getKey);
21982197
getFinishedSignal.countDown();
2199-
});
2200-
ForkJoinPool.commonPool().execute(() -> {
2198+
}).start();
2199+
new Thread(() -> {
22012200
cache.refresh(refreshKey);
22022201
getFinishedSignal.countDown();
2203-
});
2202+
}).start();
22042203

2205-
computationStarted.await();
2204+
assertTrue(computationStarted.await(300, TimeUnit.SECONDS));
22062205
cache.invalidate(getKey);
22072206
cache.invalidate(refreshKey);
22082207
assertFalse(map.containsKey(getKey));
22092208
assertFalse(map.containsKey(refreshKey));
22102209

22112210
// start new computations
2212-
ForkJoinPool.commonPool().execute(() -> {
2211+
new Thread(() -> {
22132212
cache.getUnchecked(getKey);
22142213
getFinishedSignal.countDown();
2215-
});
2216-
ForkJoinPool.commonPool().execute(() -> {
2214+
}).start();
2215+
new Thread(() -> {
22172216
cache.refresh(refreshKey);
22182217
getFinishedSignal.countDown();
2219-
});
2218+
}).start();
22202219

22212220
// let computation complete
22222221
letGetFinishSignal.countDown();
2223-
getFinishedSignal.await();
2222+
assertTrue(getFinishedSignal.await(300, TimeUnit.SECONDS));
22242223
checkNothingLogged();
22252224

22262225
// results should be visible

guava/src/test/java/jsr166/JSR166TestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.concurrent.Semaphore;
4545
import java.util.concurrent.ThreadFactory;
4646
import java.util.concurrent.ThreadPoolExecutor;
47+
import java.util.concurrent.TimeUnit;
4748
import java.util.concurrent.TimeoutException;
4849
import java.util.concurrent.atomic.AtomicReference;
4950
import java.util.regex.Pattern;
@@ -1062,7 +1063,7 @@ public Callable<String> latchAwaitingStringTask(final CountDownLatch latch) {
10621063
@Override
10631064
protected String realCall() {
10641065
try {
1065-
latch.await();
1066+
assertTrue(latch.await(300, TimeUnit.SECONDS));
10661067
} catch (InterruptedException quittingTime) {}
10671068
return TEST_STRING;
10681069
}};

0 commit comments

Comments
 (0)