use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testBasicSubmitWithMultipleStartInstancesInputEvent.
/**
* Testing for when user tries to submit a coordinator application having data-in events
* that erroneously specify multiple input data instances inside a single <start-instance> tag.
* Job gives submission error and indicates appropriate correction
* Testing both negative(error) and well as positive(success) cases
*/
public void testBasicSubmitWithMultipleStartInstancesInputEvent() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
// CASE 1: Failure case i.e. multiple data-in start-instances
Reader reader = IOUtils.getResourceAsReader("coord-multiple-input-start-instance1.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 incorrectly specified input data set start-instances");
} catch (CommandException e) {
assertEquals(sc.getJob().getStatus(), Job.Status.FAILED);
assertEquals(e.getErrorCode(), ErrorCode.E1021);
assertTrue(e.getMessage().contains(sc.COORD_INPUT_EVENTS) && e.getMessage().contains("Coordinator app definition should not have multiple start-instances"));
}
// CASE 2: Success case i.e. Single start instances for input and single start instance for output, but both with ","
reader = IOUtils.getResourceAsReader("coord-multiple-input-start-instance2.xml", -1);
writer = new FileWriter(appPathFile);
IOUtils.copyCharStream(reader, writer);
sc = new CoordSubmitXCommand(conf);
try {
sc.call();
} catch (CommandException e) {
fail("Unexpected failure: " + e);
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testSubmitReservedVars.
/**
* Don't include controls in XML.
*
* @throws Exception
*/
public void testSubmitReservedVars() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"10\" start=\"2009-02-01T01:00Z\"" + " end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>blah</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("MINUTES", "1");
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
try {
sc.call();
fail("Coord job submission should fail with reserved variable definitions.");
} catch (CommandException ce) {
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testSchemaError.
/**
* test schema error. Negative test case.
*
* @throws Exception
*/
public void testSchemaError() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequencyERROR=\"10\" start=\"2009-02-01T01:00Z\"" + " end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"60\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template>" + " </dataset> " + "<dataset name=\"local_a\" frequency=\"120\" 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("Exception expected if schema has errors!");
} catch (CommandException e) {
// should come here for schema errors
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testSubmitNoDatasets.
/**
* Don't include datasets, input-events, or output-events in XML.
*
* @throws Exception
*/
public void testSubmitNoDatasets() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"10\" start=\"2009-02-01T01:00Z\"" + " end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> " + "<controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>blah</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);
String jobId = sc.call();
assertEquals(jobId.substring(jobId.length() - 2), "-C");
checkCoordJobs(jobId);
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestCoordSubmitXCommand method testBasicSubmitWithUnMaterializableFrequency.
public void testBasicSubmitWithUnMaterializableFrequency() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"0/10 3 * * *\" start=\"2010-02-01T01:00Z\" " + "end=\"2010-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2010-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=\"2010-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 bad combination of frequency and start and end time");
} catch (CommandException e) {
assertEquals(sc.getJob().getStatus(), Job.Status.FAILED);
assertEquals(e.getErrorCode(), ErrorCode.E1003);
assertTrue(e.getMessage().contains("materializes no actions between start and end time."));
}
}
Aggregations