@Test(timeout = 1800000) public void testRpcWithChaosMonkeyWithSyncClient() throws Throwable { for (int i = 0; i < numIterations; i++) { TimeoutThread.runWithTimeout( new Callable<Void>() { @Override public Void call() throws Exception { try { testRpcWithChaosMonkey(true); } catch (Throwable e) { if (e instanceof Exception) { throw (Exception) e; } else { throw new Exception(e); } } return null; } }, 180000); } }
@Test(timeout = 900000) @Ignore // TODO: test fails with async client public void testRpcWithChaosMonkeyWithAsyncClient() throws Throwable { for (int i = 0; i < numIterations; i++) { TimeoutThread.runWithTimeout( new Callable<Void>() { @Override public Void call() throws Exception { try { testRpcWithChaosMonkey(false); } catch (Throwable e) { if (e instanceof Exception) { throw (Exception) e; } else { throw new Exception(e); } } return null; } }, 90000); } }
// runs in the same thread context but injects a timeout thread which will exit the JVM on // timeout static void runWithTimeout(Callable<?> callable, long timeout) throws Exception { TimeoutThread thread = new TimeoutThread(timeout); thread.start(); callable.call(); thread.interrupt(); }