use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestFsActionExecutor method testChmodRelativePath.
public void testChmodRelativePath() throws Exception {
FsActionExecutor ae = new FsActionExecutor();
FileSystem fs = getFileSystem();
Context context = createContext("<fs/>");
Path basePath = new Path(getFsTestCaseDir(), "2010");
createTestDirForChmod(basePath, fs);
Path globPath = new Path(basePath + "/1[0-1]");
Path relativePath = new Path(globPath.toUri().getPath());
Path nameNode = new Path(globPath.toUri().getScheme() + "://" + globPath.toUri().getAuthority());
ae.chmod(context, null, nameNode, relativePath, "-rwx------", false, false);
assertEquals("rwx------", fs.getFileStatus(new Path(basePath, "10")).getPermission().toString());
assertEquals("rwx------", fs.getFileStatus(new Path(basePath, "11")).getPermission().toString());
assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath, "12")).getPermission().toString());
assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath + "/10/dir1")).getPermission().toString());
assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath + "/10/dir2")).getPermission().toString());
assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath + "/11/dir3")).getPermission().toString());
assertEquals("rw-rw-rw-", fs.getFileStatus(new Path(basePath + "/10/dir1/file1")).getPermission().toString());
try {
ae.chmod(context, null, null, relativePath, "-rwx-----", false, false);
fail();
} catch (ActionExecutorException e) {
assertEquals(e.getErrorCode(), "FS001");
}
fs.delete(basePath, true);
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestDecisionActionExecutor method testDecision.
public void testDecision() throws Exception {
new Services().init();
try {
ActionExecutor decision = new DecisionActionExecutor();
assertEquals(DecisionActionExecutor.ACTION_TYPE, decision.getType());
WorkflowActionBean action = new WorkflowActionBean();
action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" + "<case to='a'>true</case>" + "<case to='b'>true</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
decision.start(new Context(action), action);
assertEquals(WorkflowAction.Status.DONE, action.getStatus());
decision.end(new Context(action), action);
assertEquals(WorkflowAction.Status.OK, action.getStatus());
assertEquals("a", action.getExternalStatus());
action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" + "<case to='a'>false</case>" + "<case to='b'>true</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
decision.start(new Context(action), action);
assertEquals(WorkflowAction.Status.DONE, action.getStatus());
decision.end(new Context(action), action);
assertEquals(WorkflowAction.Status.OK, action.getStatus());
assertEquals("b", action.getExternalStatus());
action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" + "<case to='a'>false</case>" + "<case to='b'>false</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
decision.start(new Context(action), action);
assertEquals(WorkflowAction.Status.DONE, action.getStatus());
decision.end(new Context(action), action);
assertEquals(WorkflowAction.Status.OK, action.getStatus());
assertEquals("d", action.getExternalStatus());
try {
action.setConf("<wrong>" + "<case to='a'>false</case>" + "<case to='b'>false</case>" + "<case to='c'>false</case>" + "<default to='d'/></switch>");
decision.start(new Context(action), action);
fail();
} catch (ActionExecutorException ex) {
assertEquals(ActionExecutorException.ErrorType.FAILED, ex.getErrorType());
assertEquals(DecisionActionExecutor.XML_ERROR, ex.getErrorCode());
} catch (Exception ex) {
fail();
}
} finally {
Services.get().destroy();
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestEmailActionExecutor method testLocalFileAttachmentError.
public void testLocalFileAttachmentError() throws Exception {
File attachFile1 = new File(getTestCaseDir() + File.separator + "attachment1.txt");
String content1 = "this is attachment content in file1";
File attachFile2 = new File(getTestCaseDir() + File.separator + "attachment2.txt");
String content2 = "this is attachment content in file2";
BufferedWriter output = new BufferedWriter(new FileWriter(attachFile1));
output.write(content1);
output.close();
output = new BufferedWriter(new FileWriter(attachFile2));
output.write(content2);
output.close();
StringBuilder tag = new StringBuilder();
tag.append("file://").append(attachFile1.getAbsolutePath()).append(",file://").append(attachFile2.getAbsolutePath());
// local file not attached to email (for security reason)
try {
assertAttachment(tag.toString(), 0, content1, content2);
fail();
} catch (ActionExecutorException e) {
assertEquals("EM008", e.getErrorCode());
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestMapReduceActionExecutor method testSetupMethods.
public void testSetupMethods() throws Exception {
MapReduceActionExecutor ae = new MapReduceActionExecutor();
List<Class<?>> classes = Arrays.<Class<?>>asList(StreamingMain.class);
assertEquals(classes, ae.getLauncherClasses());
Element actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>mapred.input.dir</name><value>IN</value></property>" + "<property><name>mapred.output.dir</name><value>OUT</value></property>" + "</configuration>" + "</map-reduce>");
XConfiguration protoConf = new XConfiguration();
protoConf.set(WorkflowAppService.HADOOP_USER, getTestUser());
WorkflowJobBean wf = createBaseWorkflow(protoConf, "mr-action");
WorkflowActionBean action = (WorkflowActionBean) wf.getActions().get(0);
action.setType(ae.getType());
Context context = new Context(wf, action);
Configuration conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
assertEquals("IN", conf.get("mapred.input.dir"));
Configuration launcherJobConf = ae.createLauncherConf(getFileSystem(), context, action, actionXml, conf);
assertEquals(false, launcherJobConf.getBoolean("mapreduce.job.complete.cancel.delegation.tokens", true));
assertEquals(true, conf.getBoolean("mapreduce.job.complete.cancel.delegation.tokens", false));
// Enable uber jars to test that MapReduceActionExecutor picks up the oozie.mapreduce.uber.jar property correctly
Services serv = Services.get();
boolean originalUberJarDisabled = serv.getConf().getBoolean("oozie.action.mapreduce.uber.jar.enable", false);
serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", true);
actionXml = createUberJarActionXML(getNameNodeUri() + "/app/job.jar", "");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
// absolute path with namenode
assertEquals(getNameNodeUri() + "/app/job.jar", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
actionXml = createUberJarActionXML("/app/job.jar", "");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
// absolute path without namenode
assertEquals(getNameNodeUri() + "/app/job.jar", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
actionXml = createUberJarActionXML("job.jar", "");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
// relative path
assertEquals(getFsTestCaseDir() + "/job.jar", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
actionXml = createUberJarActionXML("job.jar", "<streaming></streaming>");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
// ignored for streaming
assertEquals("", conf.get(MapReduceMain.OOZIE_MAPREDUCE_UBER_JAR));
actionXml = createUberJarActionXML("job.jar", "<pipes></pipes>");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
// ignored for pipes
assertEquals("", conf.get("oozie.mapreduce.uber.jar"));
actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "</map-reduce>");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
// doesn't resolve if not set
assertNull(conf.get("oozie.mapreduce.uber.jar"));
// Disable uber jars to test that MapReduceActionExecutor won't allow the oozie.mapreduce.uber.jar property
serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", false);
try {
actionXml = createUberJarActionXML(getNameNodeUri() + "/app/job.jar", "");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
fail("ActionExecutorException expected because uber jars are disabled");
} catch (ActionExecutorException aee) {
assertEquals("MR003", aee.getErrorCode());
assertEquals(ActionExecutorException.ErrorType.ERROR, aee.getErrorType());
assertTrue(aee.getMessage().contains("oozie.action.mapreduce.uber.jar.enable"));
assertTrue(aee.getMessage().contains("oozie.mapreduce.uber.jar"));
}
serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", originalUberJarDisabled);
actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<streaming>" + "<mapper>M</mapper>" + "<reducer>R</reducer>" + "<record-reader>RR</record-reader>" + "<record-reader-mapping>RRM1=1</record-reader-mapping>" + "<record-reader-mapping>RRM2=2</record-reader-mapping>" + "<env>e=E</env>" + "<env>ee=EE</env>" + "</streaming>" + "<configuration>" + "<property><name>mapred.input.dir</name><value>IN</value></property>" + "<property><name>mapred.output.dir</name><value>OUT</value></property>" + "</configuration>" + "</map-reduce>");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
assertEquals("M", conf.get("oozie.streaming.mapper"));
assertEquals("R", conf.get("oozie.streaming.reducer"));
assertEquals("RR", conf.get("oozie.streaming.record-reader"));
assertEquals("2", conf.get("oozie.streaming.record-reader-mapping.size"));
assertEquals("2", conf.get("oozie.streaming.env.size"));
actionXml = XmlUtils.parseXml("<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<pipes>" + "<map>M</map>" + "<reduce>R</reduce>" + "<inputformat>IF</inputformat>" + "<partitioner>P</partitioner>" + "<writer>W</writer>" + "<program>PP</program>" + "</pipes>" + "<configuration>" + "<property><name>mapred.input.dir</name><value>IN</value></property>" + "<property><name>mapred.output.dir</name><value>OUT</value></property>" + "</configuration>" + "</map-reduce>");
conf = ae.createBaseHadoopConf(context, actionXml);
ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
assertEquals("M", conf.get("oozie.pipes.map"));
assertEquals("R", conf.get("oozie.pipes.reduce"));
assertEquals("IF", conf.get("oozie.pipes.inputformat"));
assertEquals("P", conf.get("oozie.pipes.partitioner"));
assertEquals("W", conf.get("oozie.pipes.writer"));
assertEquals(getFsTestCaseDir() + "/PP", conf.get("oozie.pipes.program"));
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestMapReduceActionExecutor method testMapReduceWithUberJarDisabled.
// With the oozie.action.mapreduce.uber.jar.enable property set to false, a workflow with an uber jar should fail
public void testMapReduceWithUberJarDisabled() throws Exception {
Services serv = Services.get();
boolean originalUberJarDisabled = serv.getConf().getBoolean("oozie.action.mapreduce.uber.jar.enable", false);
try {
serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", false);
_testMapReduceWithUberJar();
} catch (ActionExecutorException aee) {
assertEquals("MR003", aee.getErrorCode());
assertEquals(ActionExecutorException.ErrorType.ERROR, aee.getErrorType());
assertTrue(aee.getMessage().contains("oozie.action.mapreduce.uber.jar.enable"));
assertTrue(aee.getMessage().contains("oozie.mapreduce.uber.jar"));
} catch (Exception e) {
throw e;
} finally {
serv.getConf().setBoolean("oozie.action.mapreduce.uber.jar.enable", originalUberJarDisabled);
}
}
Aggregations