public static void assertIsIllegalArgumentException(final Procedure<?> result) { Throwable cause = assertProcFailed(result); assertTrue("expected IllegalArgumentIOException, got " + cause, cause instanceof IllegalArgumentIOException); }
public static void assertIsAbortException(final Procedure<?> result) { Throwable cause = assertProcFailed(result); assertTrue("expected abort exception, got "+ cause, cause instanceof ProcedureAbortedException); }
public static void assertIsTimeoutException(final Procedure<?> result) { Throwable cause = assertProcFailed(result); assertTrue("expected TimeoutIOException, got " + cause, cause instanceof TimeoutIOException); }
public static <TEnv> Throwable assertProcFailed(final ProcedureExecutor<TEnv> procExecutor, final long procId) { Procedure<?> result = procExecutor.getResult(procId); assertTrue("expected procedure result", result != null); return assertProcFailed(result); }
@Test public void testChildOnLastStepWithRollback() { procExecutor.getEnvironment().triggerChildRollback = true; long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.waitProcedure(procExecutor, procId); assertEquals(3, procExecutor.getEnvironment().execCount.get()); assertEquals(3, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }
@Test public void testSetFailureResultForNonce() throws IOException { final long nonceGroup = 234; final long nonce = 55555; // check and register the request nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); procExecutor.setFailureResultForNonce(nonceKey, "testProc", User.getCurrent(), new IOException("test failure")); final long procId = procExecutor.registerNonce(nonceKey); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcFailed(result); }
@Test public void testChildOnLastStepWithRollbackDoubleExecution() throws Exception { procExecutor.getEnvironment().triggerChildRollback = true; ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true); long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId, true); assertEquals(6, procExecutor.getEnvironment().execCount.get()); assertEquals(6, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }
public static <TEnv> void testRecoveryAndDoubleExecution(final ProcedureExecutor<TEnv> procExec, final long procId, final boolean expectFailure, final Runnable customRestart) throws Exception { Procedure proc = procExec.getProcedure(procId); waitProcedure(procExec, procId); assertEquals(false, procExec.isRunning()); for (int i = 0; !procExec.isFinished(procId); ++i) { proc = procExec.getProcedure(procId); LOG.info("Restart " + i + " exec state: " + proc); if (customRestart != null) { customRestart.run(); } else { restart(procExec); } waitProcedure(procExec, procId); } assertEquals(true, procExec.isRunning()); if (expectFailure) { assertProcFailed(procExec, procId); } else { assertProcNotFailed(procExec, procId); } }
public static void assertIsIllegalArgumentException(final Procedure<?> result) { Throwable cause = assertProcFailed(result); assertTrue("expected IllegalArgumentIOException, got " + cause, cause instanceof IllegalArgumentIOException); }
public static void assertIsTimeoutException(final Procedure<?> result) { Throwable cause = assertProcFailed(result); assertTrue("expected TimeoutIOException, got " + cause, cause instanceof TimeoutIOException); }
public static void assertIsIllegalArgumentException(final Procedure<?> result) { Throwable cause = assertProcFailed(result); assertTrue("expected IllegalArgumentIOException, got " + cause, cause instanceof IllegalArgumentIOException); }
public static void assertIsAbortException(final Procedure<?> result) { Throwable cause = assertProcFailed(result); assertTrue("expected abort exception, got "+ cause, cause instanceof ProcedureAbortedException); }
public static <TEnv> Throwable assertProcFailed(final ProcedureExecutor<TEnv> procExecutor, final long procId) { Procedure<?> result = procExecutor.getResult(procId); assertTrue("expected procedure result", result != null); return assertProcFailed(result); }
public static <TEnv> Throwable assertProcFailed(final ProcedureExecutor<TEnv> procExecutor, final long procId) { Procedure<?> result = procExecutor.getResult(procId); assertTrue("expected procedure result", result != null); return assertProcFailed(result); }
@Test public void testChildOnLastStepWithRollback() { procExecutor.getEnvironment().triggerChildRollback = true; long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.waitProcedure(procExecutor, procId); assertEquals(3, procExecutor.getEnvironment().execCount.get()); assertEquals(3, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }
@Test public void testChildOnLastStepWithRollback() { procExecutor.getEnvironment().triggerChildRollback = true; long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.waitProcedure(procExecutor, procId); assertEquals(3, procExecutor.getEnvironment().execCount.get()); assertEquals(3, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }
@Test public void testChildOnLastStepWithRollbackDoubleExecution() throws Exception { procExecutor.getEnvironment().triggerChildRollback = true; ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true); long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId, true); assertEquals(6, procExecutor.getEnvironment().execCount.get()); assertEquals(6, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }
@Test public void testSetFailureResultForNonce() throws IOException { final long nonceGroup = 234; final long nonce = 55555; // check and register the request nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); procExecutor.setFailureResultForNonce(nonceKey, "testProc", User.getCurrent(), new IOException("test failure")); final long procId = procExecutor.registerNonce(nonceKey); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcFailed(result); }
@Test public void testSetFailureResultForNonce() throws IOException { final long nonceGroup = 234; final long nonce = 55555; // check and register the request nonce final NonceKey nonceKey = procExecutor.createNonceKey(nonceGroup, nonce); assertFalse(procExecutor.registerNonce(nonceKey) >= 0); procExecutor.setFailureResultForNonce(nonceKey, "testProc", User.getCurrent(), new IOException("test failure")); final long procId = procExecutor.registerNonce(nonceKey); Procedure<?> result = procExecutor.getResult(procId); ProcedureTestingUtility.assertProcFailed(result); }
@Test public void testChildOnLastStepWithRollbackDoubleExecution() throws Exception { procExecutor.getEnvironment().triggerChildRollback = true; ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true); long procId = procExecutor.submitProcedure(new TestSMProcedure()); ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId, true); assertEquals(6, procExecutor.getEnvironment().execCount.get()); assertEquals(6, procExecutor.getEnvironment().rollbackCount.get()); Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId); assertEquals(TEST_FAILURE_EXCEPTION, cause); }