use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordUpdateXCommand method testReRunRefresh.
// test coord re-run with refresh. will use the updated coord definition.
public void testReRunRefresh() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile1 = new File(getTestCaseDir(), "coordinator.xml");
String jobId = setupCoord(conf, "coord-multiple-input-instance3.xml");
sleep(1000);
final int actionNum = 1;
final String actionId = jobId + "@" + actionNum;
final OozieClient coordClient = LocalOozie.getCoordClient();
waitFor(120 * 1000, new Predicate() {
@Override
public boolean evaluate() throws Exception {
CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
return (bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.SUBMITTED);
}
});
CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
assertEquals(bean.getMissingDependencies(), "!!${coord:latest(0)}#${coord:latest(-1)}");
CoordinatorJobBean job = getCoordJobs(jobId);
Reader reader = IOUtils.getResourceAsReader("coord-multiple-input-instance4.xml", -1);
Writer writer = new FileWriter(appPathFile1);
IOUtils.copyCharStream(reader, writer);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile1.toURI().toString());
new CoordUpdateXCommand(false, conf, jobId).call();
job = getCoordJobs(jobId);
Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
Namespace namespace = processedJobXml.getNamespace();
String text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:future(0, 1)}");
new CoordActionsKillXCommand(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum)).call();
coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), true, true);
bean = coordClient.getCoordActionInfo(actionId);
sleep(1000);
assertEquals(bean.getMissingDependencies(), "!!${coord:future(0, 1)}");
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordUpdateXCommand method testCoordFromBundleJobChangeDefinition.
public void testCoordFromBundleJobChangeDefinition() throws Exception {
final XConfiguration jobConf = new XConfiguration();
String coordJobId = setUpBundleAndGetCoordID(jobConf);
CoordinatorJobBean job = getCoordJobs(coordJobId);
Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
Namespace namespace = processedJobXml.getNamespace();
String text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:latest(0)}");
final Path coordPath1 = new Path(getFsTestCaseDir(), "coord1");
writeCoordXml(coordPath1, "coord-multiple-input-instance4.xml");
Configuration newConf = new Configuration();
newConf.set(OozieClient.USER_NAME, getTestUser());
CoordUpdateXCommand update = new CoordUpdateXCommand(false, newConf, coordJobId);
update.call();
job = getCoordJobs(coordJobId);
processedJobXml = XmlUtils.parseXml(job.getJobXml());
namespace = processedJobXml.getNamespace();
text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:future(0, 1)}");
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordUpdateXCommand method testCoordFromBundleJobChangeConf.
public void testCoordFromBundleJobChangeConf() throws Exception {
final XConfiguration jobConf = new XConfiguration();
String coordJobId = setUpBundleAndGetCoordID(jobConf);
jobConf.set("newvalue", "yes");
CoordUpdateXCommand update = new CoordUpdateXCommand(false, jobConf, coordJobId);
update.call();
CoordinatorJobBean job = getCoordJobs(coordJobId);
Configuration xConf = new XConfiguration(new StringReader(job.getConf()));
assertEquals(xConf.get("newvalue"), "yes");
/*
* testProperty is part of bundle.xml <property> <name>testProperty</name> <value>abc</value> </property>
*/
jobConf.set("testProperty", "xyz");
new CoordUpdateXCommand(false, jobConf, coordJobId).call();
job = getCoordJobs(coordJobId);
xConf = new XConfiguration(new StringReader(job.getConf()));
assertEquals(xConf.get("testProperty"), "xyz");
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordActionReadyXCommand method _testActionsInREADY.
private void _testActionsInREADY(Execution execPolicy) throws Exception {
Date now = new Date();
Date start = new Date(now.getTime() - 16 * 60 * 1000);
Date end = new Date(now.getTime() + 20 * 60 * 1000);
CoordinatorJobBean job = createCoordJob(Job.Status.RUNNING, start, end, true, true, 5);
job.setStartTime(start);
job.setEndTime(end);
job.setExecutionOrder(execPolicy);
job.setFrequency("5");
job.setTimeUnit(Timeunit.MINUTE);
// Concurrency=1 ensures that with the 1 RUNNING action, CoordActionReadyXCommand won't actually start another action
// (CoordActionStartXCommand), which would throw an Exception because the DB only has partial info
job.setConcurrency(1);
addRecordToCoordJobTable(job);
final CoordinatorActionBean action1 = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.RUNNING, "wf-no-op.xml", 1, start);
final CoordinatorActionBean action2 = addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.READY, "wf-no-op.xml", 1, new Date(start.getTime() + 5 * 60 * 1000));
final CoordinatorActionBean action3 = addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.READY, "wf-no-op.xml", 1, new Date(start.getTime() + 10 * 60 * 1000));
final CoordinatorActionBean action4 = addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.READY, "wf-no-op.xml", 1, new Date(start.getTime() + 15 * 60 * 1000));
final CoordinatorActionBean action5 = addRecordToCoordActionTable(job.getId(), 5, CoordinatorAction.Status.WAITING, "wf-no-op.xml", 1, new Date(start.getTime() + 20 * 60 * 1000));
checkCoordActionStatus(action1.getId(), CoordinatorAction.Status.RUNNING);
checkCoordActionStatus(action2.getId(), CoordinatorAction.Status.READY);
checkCoordActionStatus(action3.getId(), CoordinatorAction.Status.READY);
checkCoordActionStatus(action4.getId(), CoordinatorAction.Status.READY);
checkCoordActionStatus(action5.getId(), CoordinatorAction.Status.WAITING);
new CoordActionReadyXCommand(job.getId()).call();
checkCoordActionStatus(action1.getId(), CoordinatorAction.Status.RUNNING);
checkCoordActionStatus(action2.getId(), CoordinatorAction.Status.SKIPPED);
checkCoordActionStatus(action3.getId(), CoordinatorAction.Status.SKIPPED);
checkCoordActionStatus(action4.getId(), CoordinatorAction.Status.READY);
checkCoordActionStatus(action5.getId(), CoordinatorAction.Status.WAITING);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordActionSkipXCommand method testVerifyPrecondition.
public void testVerifyPrecondition() throws Exception {
Date startTime = new Date();
Date endTime = new Date(startTime.getTime() + 1 * 60 * 1000);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, true, 0);
int actionNum = 1;
for (CoordinatorAction.Status actionStatus : CoordinatorAction.Status.values()) {
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), actionNum, actionStatus, "coord-action-get.xml", 0);
try {
new CoordActionSkipXCommand(action, getTestUser(), "my-app-name").verifyPrecondition();
if (!(actionStatus.equals(CoordinatorAction.Status.WAITING) || actionStatus.equals(CoordinatorAction.Status.READY))) {
fail();
}
} catch (PreconditionException pe) {
assertEquals(ErrorCode.E1100, pe.getErrorCode());
assertTrue(pe.getMessage().endsWith("[" + actionStatus + "]]"));
}
actionNum++;
}
}
Aggregations