use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testSubmitDatasetInitialInstance.
/**
* Checking that any dataset initial-instance is not set to a date earlier than the server default Jan 01, 1970 00:00Z UTC
* @throws Exception
*/
public void testSubmitDatasetInitialInstance() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
Reader reader = IOUtils.getResourceAsReader("coord-dataset-initial-instance.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "coordinator.xml"));
IOUtils.copyCharStream(reader, writer);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
try {
sc.call();
fail("Expected to catch errors due to invalid dataset initial instance");
} catch (CommandException cx) {
assertEquals(sc.getJob().getStatus(), Job.Status.FAILED);
assertEquals(cx.getErrorCode(), ErrorCode.E1021);
if (!(cx.getMessage().contains("earlier than the default initial instance"))) {
fail("Unexpected failure - " + cx.getMessage());
}
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testBasicSubmitWithDryRun.
public void testBasicSubmitWithDryRun() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"${appName}-foo\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" " + "end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template> </dataset> " + "<dataset name=\"local_a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template> </dataset> " + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in> " + "</input-events> " + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> " + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow>" + " <app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> " + "</property></configuration> </workflow> </action> </coordinator-app>";
writeToFile(appXml, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("appName", "var-app-name");
CoordSubmitXCommand sc = new CoordSubmitXCommand(true, conf);
String dryrunStr = sc.call();
String[] actions = dryrunStr.split("action for new instance");
assertEquals(actions.length, 2);
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testBasicSubmitWithStartTimeAfterEndTime.
public void testBasicSubmitWithStartTimeAfterEndTime() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2010-02-01T01:00Z\"" + " end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template>" + " </dataset> " + "<dataset name=\"local_a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template>" + " </dataset> " + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in> " + "</input-events> " + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> " + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow>" + " <app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> " + "</property></configuration> </workflow> </action> </coordinator-app>";
writeToFile(appXml, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
try {
sc.call();
fail("Expected to catch errors due to incorrectly specified Start and End Time");
} catch (CommandException e) {
assertEquals(sc.getJob().getStatus(), Job.Status.FAILED);
assertEquals(e.getErrorCode(), ErrorCode.E1003);
assertTrue(e.getMessage().contains("Coordinator Start Time must be earlier than End Time."));
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testSubmitWithTimeout.
/**
* Test timeout setting
*
* @throws Exception
*/
public void testSubmitWithTimeout() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
// timeout unit = DAY
String appXml1 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:days(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml1, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
String jobId = sc.call();
assertEquals(jobId.substring(jobId.length() - 2), "-C");
CoordinatorJobBean job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 14400);
// timeout unit = HOUR
String appXml2 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:hours(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml2, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
sc = new CoordSubmitXCommand(conf);
jobId = sc.call();
job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 600);
// timeout unit = MINUTE
String appXml3 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:minutes(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml3, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
sc = new CoordSubmitXCommand(conf);
jobId = sc.call();
job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 10);
// timeout unit = MONTH
String appXml4 = "<coordinator-app name=\"NAME\" frequency=\"${coord:months(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:months(1)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
writeToFile(appXml4, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
sc = new CoordSubmitXCommand(conf);
jobId = sc.call();
job = checkCoordJobs(jobId);
assertEquals(job.getTimeout(), 43200);
}
use of org.apache.oozie.util.XConfiguration 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)}");
}
Aggregations