use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendWithErrorPostive.
/**
* Test : suspend a RUNNINGWITHERROR coordinator job
*
* @throws Exception
*/
public void testCoordSuspendWithErrorPostive() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNINGWITHERROR, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendPostive.
/**
* Test : suspend a RUNNING coordinator job
*
* @throws Exception
*/
public void testCoordSuspendPostive() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNING);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDED);
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordUpdateXCommand method getCoordJobs.
private CoordinatorJobBean getCoordJobs(String jobId) {
try {
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorJobBean job = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
return job;
} catch (JPAExecutorException e) {
fail("Job ID " + jobId + " was not stored properly in db");
}
return null;
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordKillXCommand method testCoordKillWaiting.
/**
* Test: Kill a waiting coord action
* @throws Exception
*/
public void testCoordKillWaiting() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, true, 0);
// Create a workflow job with RUNNING status
WorkflowJobBean wfJob1 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
// Create a coordinator job with RUNNING status
CoordinatorActionBean action1 = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1.getId(), "RUNNING", 0);
// Create a coordinator job with WAITING status
CoordinatorActionBean action2 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-get.xml", null, null, 0);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd1 = new CoordActionGetJPAExecutor(action1.getId());
CoordActionGetJPAExecutor coordActionGetCmd2 = new CoordActionGetJPAExecutor(action2.getId());
coordJob = jpaService.execute(coordJobGetCmd);
action1 = jpaService.execute(coordActionGetCmd1);
action2 = jpaService.execute(coordActionGetCmd2);
// Make sure the status is updated
assertEquals(coordJob.getStatus(), CoordinatorJob.Status.RUNNING);
assertEquals(action1.getStatus(), CoordinatorAction.Status.RUNNING);
assertEquals(action2.getStatus(), CoordinatorAction.Status.WAITING);
// Issue the kill command
new CoordKillXCommand(coordJob.getId()).call();
coordJob = jpaService.execute(coordJobGetCmd);
action1 = jpaService.execute(coordActionGetCmd1);
action2 = jpaService.execute(coordActionGetCmd2);
// Check the status and pending flag after kill command is issued
assertEquals(coordJob.getStatus(), CoordinatorJob.Status.KILLED);
assertEquals(action1.getStatus(), CoordinatorAction.Status.KILLED);
// The wf job is running and can be killed, so pending for coord action
// kill should be true
assertEquals(action1.getPending(), 1);
assertEquals(action2.getStatus(), CoordinatorAction.Status.KILLED);
// The coord job is waiting and no wf created yet, so pending for coord
// action kill should be false
assertEquals(action2.getPending(), 0);
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordKillXCommand method testCoordKillForBackwardSupport.
/**
* Test : kill SUCCEEDED job successfully when CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS is true and coordinator schema
* is 0.1
*
* @throws Exception
*/
public void testCoordKillForBackwardSupport() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, true);
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
job.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_APPNAMESPACE, job);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(action.getId());
job = jpaService.execute(coordJobGetCmd);
action = jpaService.execute(coordActionGetCmd);
assertEquals(CoordinatorJob.Status.SUCCEEDED, job.getStatus());
assertEquals(CoordinatorAction.Status.RUNNING, action.getStatus());
new CoordKillXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
action = jpaService.execute(coordActionGetCmd);
assertEquals(CoordinatorJob.Status.KILLED, job.getStatus());
assertEquals(CoordinatorAction.Status.KILLED, action.getStatus());
}
Aggregations