use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestFsActionExecutor method testFileSchemeWildcard.
public void testFileSchemeWildcard() throws Exception {
FsActionExecutor ae = new FsActionExecutor();
Services.get().destroy();
setSystemProperty(HadoopAccessorService.SUPPORTED_FILESYSTEMS, "*");
new Services().init();
try {
ae.validatePath(new Path("anyfs://bla"), true);
} catch (ActionExecutorException ex) {
fail("Wildcard indicates ALL schemes will be allowed. This should pass");
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class ForTestingActionExecutor method end.
public void end(Context context, WorkflowAction action) throws ActionExecutorException {
Element eConf = getConfiguration(action.getConf());
Namespace ns = eConf.getNamespace();
String error = eConf.getChild("error", ns).getText().trim();
if ("end.transient".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "end");
}
if ("end.non-transient".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "end");
}
if ("end.error".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "end");
}
String signalValue = eConf.getChild("signal-value", ns).getText().trim();
String externalStatus = action.getExternalStatus();
WorkflowAction.Status status = null;
if (externalStatus.equals("ok")) {
status = WorkflowAction.Status.OK;
} else {
status = WorkflowAction.Status.ERROR;
}
if (signalValue.equals("based_on_action_status")) {
signalValue = status.toString();
}
boolean callSetEndData = true;
Element setEndData = eConf.getChild("avoid-set-end-data", ns);
if (null != setEndData) {
if (setEndData.getText().trim().equals("true")) {
callSetEndData = false;
}
}
if (callSetEndData) {
context.setEndData(status, signalValue);
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class ForTestingActionExecutor method start.
public void start(Context context, WorkflowAction action) throws ActionExecutorException {
Element eConf = getConfiguration(action.getConf());
Namespace ns = eConf.getNamespace();
String error = eConf.getChild("error", ns).getText().trim();
if ("start.transient".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "start");
}
if ("start.non-transient".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "start");
}
if ("start.error".equals(error)) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "start");
}
String externalStatus = eConf.getChild("external-status", ns).getText().trim();
Element externalChildIds = eConf.getChild("external-childIds", ns);
String runningMode = "sync";
Element runningModeElement = eConf.getChild("running-mode", ns);
if (null != runningModeElement) {
runningMode = runningModeElement.getText().trim();
}
if (runningMode.equals("async")) {
context.setStartData("blah", "blah", "blah");
return;
}
if (runningMode.equals("async-error")) {
context.setStartData("blah", "blah", "blah");
context.setExecutionData(externalStatus, null);
if (null != externalChildIds) {
context.setExternalChildIDs(externalChildIds.getText());
}
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "start");
}
boolean callSetExecutionData = true;
Element setStartData = eConf.getChild("avoid-set-execution-data", ns);
if (null != setStartData) {
if (setStartData.getText().trim().equals("true")) {
callSetExecutionData = false;
}
}
if (callSetExecutionData) {
context.setExecutionData(externalStatus, null);
}
if (null != externalChildIds) {
context.setExternalChildIDs(externalChildIds.getText());
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestSshActionExecutor method testJobRecover.
public void testJobRecover() throws ActionExecutorException, InterruptedException {
String baseDir = getTestCaseDir();
Path appPath = new Path(getNameNodeUri(), baseDir);
XConfiguration protoConf = new XConfiguration();
protoConf.setStrings(WorkflowAppService.HADOOP_USER, getTestUser());
XConfiguration wfConf = new XConfiguration();
wfConf.set(OozieClient.APP_PATH, appPath.toString());
WorkflowJobBean workflow = new WorkflowJobBean();
workflow.setConf(wfConf.toXmlString());
workflow.setAppPath(wfConf.get(OozieClient.APP_PATH));
workflow.setProtoActionConf(protoConf.toXmlString());
workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));
final WorkflowActionBean action = new WorkflowActionBean();
action.setId("actionId");
action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" + "<host>localhost</host>" + "<command>echo</command>" + "<capture-output/>" + "<args>\"prop1=something\"</args>" + "</ssh>");
action.setName("ssh");
final SshActionExecutor ssh = new SshActionExecutor();
final Context context = new Context(workflow, action);
ssh.start(context, action);
sleep(200);
final WorkflowActionBean action1 = new WorkflowActionBean();
action1.setId("actionId");
action1.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" + "<host>localhost</host>" + "<command>echo</command>" + "<capture-output/>" + "<args>\"prop1=nothing\"</args>" + "</ssh>");
action1.setName("ssh");
final SshActionExecutor ssh1 = new SshActionExecutor();
final Context context1 = new Context(workflow, action1);
sleep(500);
ssh1.start(context1, action1);
assertEquals(action1.getExternalId(), action.getExternalId());
waitFor(30 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
ssh.check(context1, action1);
return Status.DONE == action1.getStatus();
}
});
ssh1.end(context1, action1);
assertEquals(Status.OK, action1.getStatus());
assertEquals("something", PropertiesUtils.stringToProperties(action1.getData()).getProperty("prop1"));
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class TestSshActionExecutor method testSshStartWithInvalidXml.
/**
* test {@code SshActionExecutor.start()} method with invalid
* xml configuration
*/
public void testSshStartWithInvalidXml() throws Exception {
String baseDir = getTestCaseDir();
Path appPath = new Path(getNameNodeUri(), baseDir);
XConfiguration protoConf = new XConfiguration();
protoConf.setStrings(WorkflowAppService.HADOOP_USER, getTestUser());
XConfiguration wfConf = new XConfiguration();
wfConf.set(OozieClient.APP_PATH, appPath.toString());
WorkflowJobBean workflow = new WorkflowJobBean();
workflow.setConf(wfConf.toXmlString());
workflow.setAppPath(wfConf.get(OozieClient.APP_PATH));
workflow.setProtoActionConf(protoConf.toXmlString());
workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));
WorkflowActionBean action = new WorkflowActionBean();
action.setId("actionId");
action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'> invalid body ");
action.setName("ssh");
final SshActionExecutor ssh = new SshActionExecutor();
final Context context = new Context(workflow, action);
try {
ssh.start(context, action);
fail("testSshStartWithInvalidXml expected ex error");
} catch (ActionExecutorException ex) {
// ActionExecutorException should be thrown to pass the test
}
}
Aggregations