Thread.sleep(1000);
final WorkflowStore store = Services.get().get(WorkflowStoreService.class).create();
store.beginTrx();
List<WorkflowActionBean> actions = store.getActionsForWorkflow(jobId, false);
WorkflowActionBean action = actions.get(0);
final String actionId = action.getId();
assertEquals(WorkflowActionBean.Status.RUNNING, action.getStatus());
String actionConf = action.getConf();
String fixedActionConf = actionConf.replaceAll("async", "sync");
action.setConf(fixedActionConf);
action.setPending();
store.updateAction(action);
store.commitTrx();
store.closeTrx();
Runnable recoveryRunnable = new RecoveryRunnable(0, 60, 60);
recoveryRunnable.run();
Thread.sleep(3000);
final WorkflowStore store2 = Services.get().get(WorkflowStoreService.class).create();
assertEquals(WorkflowJob.Status.RUNNING, engine.getJob(jobId).getStatus());
store2.beginTrx();
WorkflowActionBean action2 = store2.getAction(actionId, false);
assertEquals(WorkflowActionBean.Status.RUNNING, action2.getStatus());
action2.setStatus(WorkflowActionBean.Status.PREP);
action2.setPending();
store2.updateAction(action2);
store2.commitTrx();
store2.closeTrx();
Thread.sleep(1000);
recoveryRunnable.run();
Thread.sleep(3000);
waitFor(10000, new Predicate() {
public boolean evaluate() throws Exception {
return (engine.getWorkflowAction(actionId).getStatus() == WorkflowActionBean.Status.OK);
}
});
// getPendingActions works correctly only with MYSQL - following assertsfail with hsql - to be investigated
// assertEquals(WorkflowJob.Status.SUCCEEDED, engine.getJob(jobId).getStatus());
final WorkflowStore store3 = Services.get().get(WorkflowStoreService.class).create();
store3.beginTrx();
WorkflowActionBean action3 = store3.getAction(actionId, false);
assertEquals(WorkflowActionBean.Status.OK, action3.getStatus());
store3.commitTrx();
store3.closeTrx();
}