use of org.apache.oozie.command.CommandException 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."));
}
}
use of org.apache.oozie.command.CommandException 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.command.CommandException 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.command.CommandException in project oozie by apache.
the class TestCoordUpdateXCommand method setUpBundleAndGetCoordID.
private String setUpBundleAndGetCoordID(XConfiguration jobConf) throws UnsupportedEncodingException, IOException, CommandException, JPAExecutorException {
final Path coordPath1 = new Path(getFsTestCaseDir(), "coord1");
final Path coordPath2 = new Path(getFsTestCaseDir(), "coord2");
writeCoordXml(coordPath1, "coord-multiple-input-instance3.xml");
writeCoordXml(coordPath2, "coord-multiple-input-instance3.xml");
Path bundleAppPath = new Path(getFsTestCaseDir(), "bundle");
String bundleAppXml = getBundleXml("bundle-submit-job.xml");
assertNotNull(bundleAppXml);
assertTrue(bundleAppXml.length() > 0);
bundleAppXml = bundleAppXml.replaceAll("#app_path1", Matcher.quoteReplacement(new Path(coordPath1.toString(), "coordinator.xml").toString()));
bundleAppXml = bundleAppXml.replaceAll("#app_path2", Matcher.quoteReplacement(new Path(coordPath2.toString(), "coordinator.xml").toString()));
writeToFile(bundleAppXml, bundleAppPath, "bundle.xml");
final Path appPath = new Path(bundleAppPath, "bundle.xml");
jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
jobConf.set("appName", "test");
jobConf.set(OozieClient.USER_NAME, getTestUser());
jobConf.set("coordName1", "NAME");
jobConf.set("coordName2", "coord2");
jobConf.set("isEnabled", "true");
BundleSubmitXCommand command = new BundleSubmitXCommand(jobConf);
final BundleJobBean bundleBean = (BundleJobBean) command.getJob();
bundleBean.setStartTime(new Date());
bundleBean.setEndTime(new Date());
final String jobId = command.call();
sleep(2000);
new BundleStartXCommand(jobId).call();
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);
}
});
final List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
return actions.get(0).getCoordId();
}
use of org.apache.oozie.command.CommandException in project oozie by apache.
the class TestCoordChangeXCommand method testCoordChangeXCommand.
/**
* Testing the Coordinator Change Commands with different combination of
* "Change Value"
* Changing the end time to be 20 minutes after the current time
* Changing the pause time to be 10 minutes after the current time
*
* @throws Exception
*/
public void testCoordChangeXCommand() throws StoreException, CommandException {
System.out.println("Running Test");
String jobId = "0000000-" + new Date().getTime() + "-testCoordChangeXCommand-C";
try {
addRecordToJobTable(jobId);
} catch (Exception ex) {
ex.printStackTrace();
fail("Exception thrown " + ex);
}
String pauseTime = convertDateToString(new Date().getTime() + 10 * 60 * 1000);
String endTime = convertDateToString(new Date().getTime() + 20 * 60 * 1000);
new CoordChangeXCommand(jobId, "endtime=" + endTime + ";concurrency=200").call();
try {
checkCoordJobs(jobId, DateUtils.parseDateOozieTZ(endTime), 200, null, false);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
String changeValue = "endtime=" + endTime + ";concurrency=200;pausetime=" + pauseTime;
new CoordChangeXCommand(jobId, changeValue).call();
try {
checkCoordJobs(jobId, DateUtils.parseDateOozieTZ(endTime), 200, DateUtils.parseDateOozieTZ(pauseTime), true);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
new CoordChangeXCommand(jobId, "endtime=" + endTime + ";concurrency=200;pausetime=").call();
try {
checkCoordJobs(jobId, DateUtils.parseDateOozieTZ(endTime), 200, null, true);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
new CoordChangeXCommand(jobId, "endtime=" + endTime + ";pausetime=;concurrency=200").call();
try {
checkCoordJobs(jobId, DateUtils.parseDateOozieTZ(endTime), 200, null, true);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
new CoordChangeXCommand(jobId, "endtime=2012-12-20T05:00Z;concurrency=-200").call();
try {
checkCoordJobs(jobId, DateUtils.parseDateOozieTZ("2012-12-20T05:00Z"), -200, null, false);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
new CoordChangeXCommand(jobId, "endtime=2012-12-20T05:00Z").call();
try {
checkCoordJobs(jobId, DateUtils.parseDateOozieTZ("2012-12-20T05:00Z"), null, null, false);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
new CoordChangeXCommand(jobId, "concurrency=-1").call();
try {
checkCoordJobs(jobId, null, -1, null, false);
} catch (Exception ex) {
ex.printStackTrace();
fail("Invalid date" + ex);
}
try {
new CoordChangeXCommand(jobId, "a=1;b=-200").call();
fail("Should not reach here.");
} catch (CommandException ex) {
if (ex.getErrorCode() != ErrorCode.E1015) {
fail("Error code should be E1015.");
}
}
try {
new CoordChangeXCommand(jobId, "endtime=2012-12-20T05:00;concurrency=-200").call();
fail("Should not reach here.");
} catch (CommandException ex) {
if (ex.getErrorCode() != ErrorCode.E1015) {
fail("Error code should be E1015.");
}
}
try {
new CoordChangeXCommand(jobId, "endtime=2012-12-20T05:00Z;concurrency=2ac").call();
fail("Should not reach here.");
} catch (CommandException ex) {
if (ex.getErrorCode() != ErrorCode.E1015) {
fail("Error code should be E1015.");
}
}
try {
new CoordChangeXCommand(jobId, "endtime=1900-12-20T05:00Z").call();
} catch (CommandException ex) {
fail("Should not throw exception");
}
try {
new CoordChangeXCommand(jobId, "pausetime=null").call();
fail("Should not reach here.");
} catch (CommandException ex) {
if (ex.getErrorCode() != ErrorCode.E1015) {
fail("Error code should be E1015.");
}
}
try {
new CoordChangeXCommand(jobId, "pausetime=" + pauseTime).call();
} catch (CommandException ex) {
fail("Should not throw exception");
}
}
Aggregations