use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestJavaActionExecutor method testCredentialsInvalid.
public void testCredentialsInvalid() throws Exception {
String workflowXml = "<workflow-app xmlns='uri:oozie:workflow:0.2.5' name='pig-wf'>" + "<credentials>" + "<credential name='abcname' type='abc'>" + "<property>" + "<name>property1</name>" + "<value>value1</value>" + "</property>" + "<property>" + "<name>property2</name>" + "<value>value2</value>" + "</property>" + "<property>" + "<name>${property3}</name>" + "<value>${value3}</value>" + "</property>" + "</credential>" + "</credentials>" + "<start to='pig1' />" + "<action name='pig1' cred='abcname'>" + "<pig>" + "</pig>" + "<ok to='end' />" + "<error to='fail' />" + "</action>" + "<kill name='fail'>" + "<message>Pig failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>" + "</kill>" + "<end name='end' />" + "</workflow-app>";
JavaActionExecutor ae = new JavaActionExecutor();
WorkflowJobBean wfBean = addRecordToWfJobTable("test1", workflowXml);
WorkflowActionBean action = (WorkflowActionBean) wfBean.getActions().get(0);
action.setType(ae.getType());
action.setCred("invalidabcname");
String actionXml = "<pig>" + "<job-tracker>${jobTracker}</job-tracker>" + "<name-node>${nameNode}</name-node>" + "<prepare>" + "<delete path='outputdir' />" + "</prepare>" + "<configuration>" + "<property>" + "<name>mapred.compress.map.output</name>" + "<value>true</value>" + "</property>" + "<property>" + "<name>mapred.job.queue.name</name>" + "<value>${queueName}</value>" + "</property>" + "</configuration>" + "<script>org/apache/oozie/examples/pig/id.pig</script>" + "<param>INPUT=${inputDir}</param>" + "<param>OUTPUT=${outputDir}/pig-output</param>" + "</pig>";
action.setConf(actionXml);
Context context = new Context(wfBean, action);
Element actionXmlconf = XmlUtils.parseXml(action.getConf());
// action job configuration
Configuration actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
try {
// Setting the credential properties in launcher conf should fail
ae.setCredentialPropertyToActionConf(context, action, actionConf);
} catch (ActionExecutorException e) {
assertEquals(e.getErrorCode(), "JA021");
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestJavaActionExecutor method testFilesystemScheme.
public void testFilesystemScheme() throws Exception {
try {
String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>";
Element eActionXml = XmlUtils.parseXml(actionXml);
Context context = createContext(actionXml, null);
Path appPath = new Path("localfs://namenode:port/mydir");
JavaActionExecutor ae = new JavaActionExecutor();
Configuration conf = ae.createBaseHadoopConf(context, eActionXml);
Services.get().destroy();
setSystemProperty(HadoopAccessorService.SUPPORTED_FILESYSTEMS, "hdfs,viewfs");
new Services().init();
ae.setupActionConf(conf, context, eActionXml, appPath);
fail("Supposed to throw exception due to unsupported fs scheme - localfs");
} catch (ActionExecutorException ae) {
assertTrue(ae.getMessage().contains("E0904"));
assertTrue(ae.getMessage().contains("Scheme [localfs] not supported"));
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestFsActionExecutor method testvalidateSameNN.
public void testvalidateSameNN() throws Exception {
FsActionExecutor ae = new FsActionExecutor();
ae.validateSameNN(new Path("hdfs://x/bla"), new Path("hdfs://x/foo"));
try {
ae.validateSameNN(new Path("hdfs://x/bla"), new Path("viefs://x/bla"));
fail();
} catch (ActionExecutorException ex) {
assertEquals("FS007", ex.getErrorCode());
}
try {
ae.validateSameNN(new Path("hdfs://x/bla"), new Path("hdfs://y/bla"));
fail();
} catch (ActionExecutorException ex) {
assertEquals("FS007", ex.getErrorCode());
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestFsActionExecutor method testValidatePath.
public void testValidatePath() throws Exception {
FsActionExecutor ae = new FsActionExecutor();
ae.validatePath(new Path("hdfs://x/bla"), true);
ae.validatePath(new Path("bla"), false);
try {
ae.validatePath(new Path("hdfs://x/bla"), false);
fail();
} catch (ActionExecutorException ex) {
assertEquals("FS002", ex.getErrorCode());
}
try {
ae.validatePath(new Path("bla"), true);
fail();
} catch (ActionExecutorException ex) {
assertEquals("FS001", ex.getErrorCode());
}
// testing schemes supported
Services.get().destroy();
setSystemProperty(HadoopAccessorService.SUPPORTED_FILESYSTEMS, "hdfs,viewfs");
new Services().init();
try {
ae.validatePath(new Path("viewfs://bla"), true);
} catch (ActionExecutorException ex) {
fail("viewfs is a supported scheme. This should not throw exception");
}
try {
ae.validatePath(new Path("file://bla"), true);
fail("file is not a supported scheme. This should throw exception");
} catch (ActionExecutorException ex) {
assertTrue(ex.getMessage().contains("E0904"));
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestFsActionExecutor method testRecovery.
public void testRecovery() throws Exception {
FsActionExecutor ae = new FsActionExecutor();
FileSystem fs = getFileSystem();
Path mkdir = new Path(getFsTestCaseDir(), "mkdir");
Path delete = new Path(getFsTestCaseDir(), "delete");
fs.mkdirs(delete);
Path source = new Path(getFsTestCaseDir(), "source");
fs.mkdirs(source);
Path target = new Path(new Path(getFsTestCaseDir(), "target").toUri().getPath());
Path chmod1 = new Path(getFsTestCaseDir(), "chmod1");
fs.mkdirs(chmod1);
Path child1 = new Path(chmod1, "child1");
fs.mkdirs(child1);
Path chmod2 = new Path(getFsTestCaseDir(), "chmod2");
fs.mkdirs(chmod2);
Path child2 = new Path(chmod2, "child2");
fs.mkdirs(child2);
String actionXml = MessageFormat.format("<fs>" + "<mkdir path=''{0}''/>" + "<delete path=''{1}''/>" + "<move source=''{2}'' target=''{3}''/>" + "<chmod path=''{4}'' permissions=''111''/>" + "<chmod path=''{5}'' permissions=''222'' dir-files=''false''/>" + "</fs>", mkdir, delete, source.toUri().getPath(), target, chmod1, chmod2);
String id = "ID" + System.currentTimeMillis();
Context context = createContext(actionXml);
((WorkflowJobBean) context.getWorkflow()).setId(id);
((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setJobId(id);
((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setId(id + "-FS");
WorkflowAction action = context.getAction();
assertFalse(fs.exists(ae.getRecoveryPath(context)));
try {
ae.start(context, action);
} catch (ActionExecutorException ex) {
if (!ex.getErrorCode().equals("FS001")) {
throw ex;
}
}
assertTrue(fs.exists(mkdir));
assertFalse(fs.exists(delete));
assertTrue(fs.exists(ae.getRecoveryPath(context)));
actionXml = MessageFormat.format("<fs>" + "<mkdir path=''{0}''/>" + "<delete path=''{1}''/>" + "<move source=''{2}'' target=''{3}''/>" + "<chmod path=''{4}'' permissions=''-rwxrwxrwx''/>" + "<chmod path=''{5}'' permissions=''-rwxrwx---'' dir-files=''false''/>" + "</fs>", mkdir, delete, source, target, chmod1, chmod2);
context = createContext(actionXml);
((WorkflowJobBean) context.getWorkflow()).setId(id);
((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setJobId(id);
((WorkflowActionBean) context.getWorkflow().getActions().get(0)).setId(id + "-FS");
action = context.getAction();
ae.start(context, action);
ae.check(context, context.getAction());
assertEquals("OK", context.getAction().getExternalStatus());
assertNull(context.getAction().getData());
ae.end(context, context.getAction());
assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
assertFalse(fs.exists(ae.getRecoveryPath(context)));
assertTrue(fs.exists(mkdir));
assertFalse(fs.exists(delete));
assertFalse(fs.exists(source));
assertTrue(fs.exists(target));
assertEquals("rwxrwxrwx", fs.getFileStatus(chmod1).getPermission().toString());
assertNotSame("rwxrwxrwx", fs.getFileStatus(child1).getPermission().toString());
assertEquals("rwxrwx---", fs.getFileStatus(chmod2).getPermission().toString());
assertNotSame("rwxrwx---", fs.getFileStatus(child2).getPermission().toString());
}
Aggregations