@Override public void testLogic() { new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); await().and().dontCatchUncaughtExceptions().given().timeout(ONE_SECOND).until(value(), equalTo(1)); } };
@Test public void checkThatAsyncEventListenersUseAllThreadsInPool() { InternalDistributedSystem ds = Fakes.distributedSystem(); CacheConfig cc = new CacheConfig(); TypeRegistry typeRegistry = mock(TypeRegistry.class); GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(ds, cc, typeRegistry); try { ThreadPoolExecutor executor = (ThreadPoolExecutor) gfc.getEventThreadPool(); assertEquals(0, executor.getCompletedTaskCount()); assertEquals(0, executor.getActiveCount()); int MAX_THREADS = GemFireCacheImpl.EVENT_THREAD_LIMIT; final CountDownLatch cdl = new CountDownLatch(MAX_THREADS); for (int i = 1; i <= MAX_THREADS; i++) { executor.execute(() -> { cdl.countDown(); try { cdl.await(); } catch (InterruptedException e) { } }); } await().timeout(90, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(MAX_THREADS, executor.getCompletedTaskCount())); } finally { gfc.close(); } }
.timeout(15, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(true, e.isWaitingOnRelease())); assertEquals(true, e.offHeapOk); .timeout(15, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(true, e.isAboutToCallGetNewValue() && e.isAboutToCallGetOldValue() .timeout(15, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(true, e.hasFinishedCallOfGetNewValue())); doGetNewValue.join(); .timeout(15, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(true, e.hasFinishedCallOfGetOldValue())); doGetOldValue.join(); .timeout(15, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(true, e.hasFinishedCallOfSerializedNew())); doSNVgetSerializedValue.join(); .timeout(15, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(true, e.hasFinishedCallOfDeserializedNew())); doSNVgetDeserializedValue.join(); .timeout(15, TimeUnit.SECONDS) .untilAsserted(() -> assertEquals(true, e.hasFinishedCallOfSerializedOld())); doSOVgetSerializedValue.join(); .timeout(15, TimeUnit.SECONDS)
private static void tearDownTables(KeyValueService kvs) { // do not truncate the targeted sweep table identifier tables Schemas.truncateTablesAndIndexes(TargetedSweepSchema.schemaWithoutTableIdentifierTables(), kvs); Awaitility.await() .timeout(Duration.FIVE_MINUTES) .until(() -> { kvs.getAllTableNames().stream() .filter(ref -> !TargetedSweepSchema.INSTANCE.getLatestSchema().getAllTables().contains(ref)) .forEach(kvs::truncateTable); return true; }); } }
private static void tearDownTables(KeyValueService kvs) { // do not truncate the targeted sweep table identifier tables Schemas.truncateTablesAndIndexes(TargetedSweepSchema.schemaWithoutTableIdentifierTables(), kvs); Awaitility.await() .timeout(Duration.FIVE_MINUTES) .until(() -> { kvs.getAllTableNames().stream() .filter(ref -> !TargetedSweepSchema.INSTANCE.getLatestSchema().getAllTables().contains(ref)) .forEach(kvs::truncateTable); return true; }); } }
void waitUntilReady() { System.out.println( ">> Riak HealthCheck BEGIN" ); Instant start = Instant.now(); Awaitility.await() .pollDelay( Duration.ZERO ) .pollInterval( Duration.ONE_SECOND ) .timeout( Duration.ONE_MINUTE ) .until( new HealthCheck() ); System.out.println( ">> Riak HealthCheck END, took " + java.time.Duration.between( start, Instant.now() ) ); }