use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleStartXCommand method testBundleStart2.
/**
* Test : Start bundle job
*
* @throws Exception
*/
public void testBundleStart2() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Configuration jobConf = null;
try {
jobConf = new XConfiguration(new StringReader(job.getConf()));
} catch (IOException ioe) {
log.warn("Configuration parse error. read from DB :" + job.getConf(), ioe);
throw new CommandException(ErrorCode.E1005, ioe);
}
Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf);
submitCmd.call();
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals("bundle-app-name", job.getAppName());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.PREP);
new BundleStartXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.RUNNING);
sleep(2000);
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(2, actions.size());
final String jobId = job.getId();
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
return actions.get(0).getStatus().equals(Job.Status.RUNNING) && actions.get(1).getStatus().equals(Job.Status.RUNNING);
}
});
actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(Job.Status.RUNNING, actions.get(0).getStatus());
assertEquals(true, actions.get(0).isCritical());
assertEquals(job.getId(), actions.get(0).getBundleId());
assertEquals(Job.Status.RUNNING, actions.get(1).getStatus());
assertEquals(false, actions.get(1).isCritical());
assertEquals(job.getId(), actions.get(1).getBundleId());
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleStartXCommand method testBundleStartNegative2.
/**
* Test : Start bundle job that contains bad coordinator job
*
* @throws Exception
*/
public void testBundleStartNegative2() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTableNegative(Job.Status.PREP);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
final BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.PREP);
new BundleStartXCommand(job.getId()).call();
waitFor(120000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean job1 = jpaService.execute(bundleJobGetExecutor);
return job1.getStatus().equals(Job.Status.FAILED);
}
});
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(Job.Status.FAILED, job.getStatus());
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleStartXCommand method testBundleStart1.
/**
* Test : Start bundle job
*
* @throws Exception
*/
public void testBundleStart1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.PREP);
new BundleStartXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.RUNNING);
sleep(2000);
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(2, actions.size());
assertEquals(true, actions.get(0).isCritical());
assertEquals(job.getId(), actions.get(0).getBundleId());
assertEquals(false, actions.get(1).isCritical());
assertEquals(job.getId(), actions.get(0).getBundleId());
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestPurgeService method testPurgeServiceForBundle.
/**
* Tests the {@link org.apache.oozie.service.PurgeService}.
* </p>
* Creates a new Bundle 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 testPurgeServiceForBundle() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
final String jobId = job.getId();
this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.SUCCEEDED);
this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.SUCCEEDED);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(Job.Status.SUCCEEDED, job.getStatus());
BundleActionGetJPAExecutor bundleActionGetExecutor1 = new BundleActionGetJPAExecutor(job.getId(), "action1");
BundleActionBean action1 = jpaService.execute(bundleActionGetExecutor1);
assertEquals(Job.Status.SUCCEEDED, action1.getStatus());
BundleActionGetJPAExecutor bundleActionGetExecutor2 = new BundleActionGetJPAExecutor(job.getId(), "action2");
BundleActionBean action2 = jpaService.execute(bundleActionGetExecutor2);
assertEquals(Job.Status.SUCCEEDED, action2.getStatus());
Runnable purgeRunnable = new PurgeRunnable(1, 1, 1, 100);
purgeRunnable.run();
final BundleEngine engine = new BundleEngine("u");
waitFor(10000, new Predicate() {
public boolean evaluate() throws Exception {
try {
engine.getBundleJob(jobId).getStatus();
} catch (Exception ex) {
return true;
}
return false;
}
});
try {
job = jpaService.execute(bundleJobGetExecutor);
fail("Job should be purged. Should fail.");
} catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}
try {
jpaService.execute(bundleActionGetExecutor1);
fail("Action should be purged. Should fail.");
} catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}
try {
jpaService.execute(bundleActionGetExecutor2);
fail("Action should be purged. Should fail.");
} catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestStatusTransitService method testBundleStatusTransitServiceSucceeded3.
/**
* Test : all coord jobs are succeeded - bundle job's status will be updated to succeeded after suspend and resume.
* coordinator action -> coordinator job -> bundle action -> bundle job
*
* @throws Exception
*/
public void testBundleStatusTransitServiceSucceeded3() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
final String bundleId = job.getId();
addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.RUNNING);
addRecordToBundleActionTable(bundleId, "action2", 0, Job.Status.RUNNING);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
addRecordToCoordJobTableWithBundle(bundleId, "action1", CoordinatorJob.Status.RUNNING, start, end, true, true, 2);
addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.RUNNING, start, end, true, true, 2);
addRecordToCoordActionTable("action1", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable("action1", 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable("action2", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable("action2", 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
new BundleJobSuspendXCommand(bundleId).call();
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.SUSPENDED, job.getStatus());
sleep(3000);
new BundleJobResumeXCommand(bundleId).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.RUNNING, job.getStatus());
}
Aggregations