use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestPurgeService method testPurgeServiceForCoordinator.
/**
* Tests the {@link org.apache.oozie.service.PurgeService}.
* </p>
* Creates a new coordinator job. Attempts to purge jobs older than a day.
* Verifies the presence of the job in the system.
* </p>
* Sets the end date for the same job to make it qualify for the purge criteria.
* Calls the purge service, and ensure the job does not exist in the system.
*/
public void testPurgeServiceForCoordinator() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, start, end, false, false, 0);
final String jobId = job.getId();
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetExecutor = new CoordJobGetJPAExecutor(job.getId());
CoordActionGetJPAExecutor coordActionGetExecutor = new CoordActionGetJPAExecutor(action.getId());
job = jpaService.execute(coordJobGetExecutor);
action = jpaService.execute(coordActionGetExecutor);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
assertEquals(action.getStatus(), CoordinatorAction.Status.SUCCEEDED);
Runnable purgeRunnable = new PurgeRunnable(1, 1, 1, 100);
purgeRunnable.run();
final CoordinatorEngine engine = new CoordinatorEngine("u");
waitFor(10000, new Predicate() {
public boolean evaluate() throws Exception {
try {
engine.getCoordJob(jobId).getStatus();
} catch (Exception ex) {
return true;
}
return false;
}
});
try {
job = jpaService.execute(coordJobGetExecutor);
fail("Job should be purged. Should fail.");
} catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}
try {
jpaService.execute(coordActionGetExecutor);
fail("Action should be purged. Should fail.");
} catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestRecoveryService method checkCoordActionDependencies.
private CoordinatorActionBean checkCoordActionDependencies(String actionId, String expDeps) throws Exception {
try {
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
assertEquals(expDeps, action.getPushMissingDependencies());
return action;
} catch (JPAExecutorException se) {
throw new Exception("Action ID " + actionId + " was not stored properly in db");
}
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionStartXCommand method checkCoordAction.
private void checkCoordAction(String actionId) {
try {
final JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
}
if (action.getExternalId() != null) {
WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(action.getExternalId()));
assertEquals(wfJob.getParentId(), action.getId());
}
} catch (JPAExecutorException je) {
fail("Action ID " + actionId + " was not stored properly in db");
}
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionStartXCommand method testActionStartWithEscapeStrings.
/**
* Test : configuration contains url string which should be escaped before put into the evaluator.
* If not escape, the error 'SAXParseException' will be thrown and workflow job will not be submitted.
*
* @throws Exception
*/
public void testActionStartWithEscapeStrings() throws Exception {
Date start = DateUtils.parseDateOozieTZ("2009-12-15T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-12-16T01:00Z");
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
CoordinatorActionBean action = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUBMITTED, "coord-action-start-escape-strings.xml", 0);
String actionId = action.getId();
new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call();
final JPAService jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
}
final String wfId = action.getExternalId();
waitFor(3000, new Predicate() {
public boolean evaluate() throws Exception {
List<WorkflowActionBean> wfActions = jpaService.execute(new WorkflowActionsGetForJobJPAExecutor(wfId));
return wfActions.size() > 0;
}
});
List<WorkflowActionBean> wfActions = jpaService.execute(new WorkflowActionsGetForJobJPAExecutor(wfId));
assertTrue(wfActions.size() > 0);
final String wfActionId = wfActions.get(0).getId();
waitFor(20 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowActionBean wfAction = jpaService.execute(new WorkflowActionGetJPAExecutor(wfActionId));
return wfAction.getExternalId() != null;
}
});
WorkflowActionBean wfAction = jpaService.execute(new WorkflowActionGetJPAExecutor(wfActionId));
assertNotNull(wfAction.getExternalId());
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionUpdatePushMissingDependency method checkCoordAction.
private CoordinatorActionBean checkCoordAction(String actionId, String expDeps, CoordinatorAction.Status stat) throws Exception {
try {
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
String missDeps = action.getPushMissingDependencies();
assertEquals(missDeps, expDeps);
assertEquals(action.getStatus(), stat);
return action;
} catch (JPAExecutorException se) {
throw new Exception("Action ID " + actionId + " was not stored properly in db");
}
}
Aggregations