Merge pull request #1611 from metamx/betterTimingTests2789

Better handling of slow stuff in NamespaceExtractionCacheManagerExecutorsTest
This commit is contained in:
Fangjin Yang 2015-08-07 15:39:04 -07:00
commit 2d22bcc11b
1 changed files with 15 additions and 2 deletions

View File

@ -280,6 +280,7 @@ public class NamespaceExtractionCacheManagerExecutorsTest
null
);
final String cacheId = UUID.randomUUID().toString();
final CountDownLatch latchBeforeMore = new CountDownLatch(1);
ListenableFuture<?> future =
manager.schedule(
namespace, factory, new Runnable()
@ -301,17 +302,29 @@ public class NamespaceExtractionCacheManagerExecutorsTest
}
finally {
latch.countDown();
try {
if (latch.getCount() == 0) {
latchBeforeMore.await();
}
}
catch (InterruptedException e) {
log.debug("Interrupted");
Thread.currentThread().interrupt();
}
finally {
latchMore.countDown();
}
}
}
},
cacheId
);
latch.await();
prior = runs.get();
latchBeforeMore.countDown();
Assert.assertFalse(future.isCancelled());
Assert.assertFalse(future.isDone());
Assert.assertTrue(fnCache.containsKey(ns));
prior = runs.get();
latchMore.await();
Assert.assertTrue(runs.get() > prior);