use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordActionsKillXCommand method testActionKillCommandActionNumbers.
/**
* Test the working of CoordActionKillXCommand by passing range
* as action ids
*
* @throws Exception
*/
public void testActionKillCommandActionNumbers() throws Exception {
JPAService jpaService = services.get(JPAService.class);
String[] ids = createDBRecords();
new CoordActionsKillXCommand(ids[0], "action", "1,3").call();
CoordinatorActionBean action = jpaService.execute(new CoordActionGetForCheckJPAExecutor(ids[1]));
assertEquals(CoordinatorAction.Status.KILLED, action.getStatus());
sleep(100);
WorkflowJobBean wf = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_FOR_SLA, ids[3]);
assertEquals(WorkflowJob.Status.KILLED, wf.getStatus());
CoordinatorJobBean job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
assertEquals(CoordinatorJob.Status.RUNNING, job.getStatus());
Runnable runnable = new StatusTransitRunnable();
runnable.run();
job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
assertEquals(CoordinatorJob.Status.RUNNINGWITHERROR, job.getStatus());
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordChangeXCommand method testCoordChangeEndTime.
/**
* test end time change : pending should mark false if job is running with
* pending true
* Changing the end time to be 40 minutes after the current time
* Changing the pause time to be 10 minutes after the current time
*
* @throws Exception
*/
public void testCoordChangeEndTime() throws Exception {
Date startTime = new Date();
Date endTime = new Date(startTime.getTime() + (20 * 60 * 1000));
final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, true, true, 0);
String pauseTime = convertDateToString(startTime.getTime() + 10 * 60 * 1000);
String newEndTime = convertDateToString(startTime.getTime() + 40 * 60 * 1000);
new CoordChangeXCommand(job.getId(), "endtime=" + newEndTime + ";pausetime=" + pauseTime).call();
try {
checkCoordJobs(job.getId(), DateUtils.parseDateOozieTZ(newEndTime), null, DateUtils.parseDateOozieTZ(pauseTime), true);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
JPAService jpaService = Services.get().get(JPAService.class);
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
assertEquals(Job.Status.RUNNING, coordJob.getStatus());
assertFalse(coordJob.isDoneMaterialization());
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordChangeXCommand method checkCoordJobs.
private void checkCoordJobs(String jobId, Date endTime, Integer concurrency, Date pauseTime, boolean checkPauseTime) throws StoreException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(jobId);
CoordinatorJobBean job = null;
job = jpaService.execute(coordGetCmd);
if (endTime != null) {
Date d = job.getEndTime();
if (d.compareTo(endTime) != 0) {
fail("Endtime is not updated properly job_end_time=" + d + ", expected_end_time=" + endTime);
}
CoordinatorJob.Status status = job.getStatus();
if (status != CoordinatorJob.Status.RUNNING) {
fail("Coordinator job's status is not updated properly");
}
}
if (concurrency != null) {
int c = job.getConcurrency();
if (c != concurrency) {
fail("Concurrency is not updated properly");
}
}
if (checkPauseTime) {
Date d = job.getPauseTime();
if (pauseTime == null) {
if (d != null) {
fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
}
} else {
if (d.compareTo(pauseTime) != 0) {
fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
}
}
}
} catch (JPAExecutorException e) {
e.printStackTrace();
}
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordChangeXCommand method testCoordStatus_Failed.
// Status change from failed- successful
public void testCoordStatus_Failed() throws Exception {
Date start = new Date();
// 5 hrs
Date end = new Date(start.getTime() + (5 * HOURS_IN_MS));
String status = "status=RUNNING";
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.FAILED, start, end, end, true, false, 4);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
try {
new CoordChangeXCommand(job.getId(), status).call();
JPAService jpaService = Services.get().get(JPAService.class);
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
assertEquals(coordJob.getStatusStr(), "RUNNING");
} catch (CommandException e) {
e.printStackTrace();
if (e.getErrorCode() != ErrorCode.E1022) {
fail("Error code should be E1022");
}
}
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordChangeXCommand method testCoordChangeEndTime3.
/**
* Testcase when changing end-time to after original end-time
* but before nextMaterializedTime should not cause unnecessary changes
*
* @throws Exception
*/
public void testCoordChangeEndTime3() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
Date startTime = new Date();
Date endTime = new Date(startTime.getTime() + (10 * 60 * 1000));
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, true, true, 1);
coordJob.setNextMaterializedTime(new Date(startTime.getTime() + (40 * 60 * 1000)));
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, coordJob);
addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
Runnable runnable = new StatusTransitService.StatusTransitRunnable();
runnable.run();
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
coordJob = jpaService.execute(coordGetCmd);
assertEquals(Job.Status.SUCCEEDED, coordJob.getStatus());
assertFalse(coordJob.isPending());
assertTrue(coordJob.isDoneMaterialization());
String newEndTime = convertDateToString(startTime.getTime() + 20 * 60 * 1000);
try {
new CoordChangeXCommand(coordJob.getId(), "endtime=" + newEndTime).call();
} catch (Exception e) {
assertTrue(e.getMessage().contains("Didn't change endtime. Endtime is in between coord end time and next materialization time"));
}
coordJob = jpaService.execute(coordGetCmd);
assertFalse(Job.Status.RUNNING == coordJob.getStatus());
assertFalse(coordJob.isPending());
assertTrue(coordJob.isDoneMaterialization());
}
Aggregations