use of org.apache.oozie.action.hadoop.MapReduceActionExecutor in project oozie by apache.
the class TestRecoveryService method testWorkflowActionRecoveryUserRetry.
/**
* Tests functionality of the Recovery Service Runnable command. </p> Starts an action with USER_RETRY status.
* Runs the recovery runnable, and ensures the state changes to OK and the job completes successfully.
*
* @throws Exception
*/
public void testWorkflowActionRecoveryUserRetry() throws Exception {
final JPAService jpaService = Services.get().get(JPAService.class);
WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.USER_RETRY);
WorkflowJobBean job2 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action2 = createWorkflowActionSetPending(job2.getId(), WorkflowAction.Status.USER_RETRY);
// Default recovery created time is 7 days.
action2.setCreatedTime(new Date(new Date().getTime() - 8 * RecoveryService.ONE_DAY_MILLISCONDS));
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action2);
jpaService.execute(actionInsertCmd);
Runnable recoveryRunnable = new RecoveryRunnable(0, 60, 60);
recoveryRunnable.run();
sleep(3000);
final WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action1.getId());
waitFor(5000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowActionBean a = jpaService.execute(wfActionGetCmd);
return a.getExternalId() != null;
}
});
action1 = jpaService.execute(wfActionGetCmd);
assertNotNull(action1.getExternalId());
assertEquals(WorkflowAction.Status.RUNNING, action1.getStatus());
// Action 2 should not get recover as it's created time is older then 7 days
action2 = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION, action2.getId());
assertNull(action2.getExternalId());
assertEquals(WorkflowAction.Status.USER_RETRY, action2.getStatus());
ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(job1, action1, false, false);
MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(action1.getConf()));
String launcherId = action1.getExternalId();
waitUntilYarnAppDoneAndAssertSuccess(launcherId);
Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
assertTrue(LauncherHelper.hasIdSwap(actionData));
}
Aggregations