* bundle job
*
* @throws Exception
*/
public void testBundleStatusTransitServiceSuspended() throws Exception {
BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.SUSPENDED, true);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
final String bundleId = bundleJob.getId();
addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.SUSPENDED);
addRecordToBundleActionTable(bundleId, "action2", 1, Job.Status.SUSPENDED);
addRecordToCoordJobTableWithBundle(bundleId, "action1", CoordinatorJob.Status.RUNNING, false, false, 2);
addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.RUNNING, false, false, 2);
final CoordinatorActionBean coordAction1_1 = addRecordToCoordActionTable("action1", 1,
CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
final CoordinatorActionBean coordAction1_2 = addRecordToCoordActionTable("action1", 2,
CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
final CoordinatorActionBean coordAction1_3 = addRecordToCoordActionTable("action2", 1,
CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
final CoordinatorActionBean coordAction1_4 = addRecordToCoordActionTable("action2", 2,
CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
this.addRecordToWfJobTable(coordAction1_1.getExternalId(), WorkflowJob.Status.RUNNING,
WorkflowInstance.Status.RUNNING);
this.addRecordToWfJobTable(coordAction1_2.getExternalId(), WorkflowJob.Status.RUNNING,
WorkflowInstance.Status.RUNNING);
this.addRecordToWfJobTable(coordAction1_3.getExternalId(), WorkflowJob.Status.RUNNING,
WorkflowInstance.Status.RUNNING);
this.addRecordToWfJobTable(coordAction1_4.getExternalId(), WorkflowJob.Status.RUNNING,
WorkflowInstance.Status.RUNNING);
new CoordSuspendXCommand("action1").call();
new CoordSuspendXCommand("action2").call();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowJobBean wfJob = jpaService
.execute(new WorkflowJobGetJPAExecutor(coordAction1_4.getExternalId()));
return wfJob.getStatus().equals(Job.Status.SUSPENDED);
}
});
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
return bundle.isPending() == false;
}
});
bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
assertFalse(bundleJob.isPending());