use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestSubWorkflowActionExecutor method testSubWorkflowRecovery.
public void testSubWorkflowRecovery() throws Exception {
Path subWorkflowAppPath = getFsTestCaseDir();
FileSystem fs = getFileSystem();
Path workflowPath = new Path(subWorkflowAppPath, "workflow.xml");
Writer writer = new OutputStreamWriter(fs.create(workflowPath));
writer.write(APP1);
writer.close();
XConfiguration protoConf = getBaseProtoConf();
WorkflowJobBean workflow = createBaseWorkflow(protoConf, "W");
final WorkflowActionBean action = (WorkflowActionBean) workflow.getActions().get(0);
action.setConf("<sub-workflow xmlns='uri:oozie:workflow:0.1'>" + " <app-path>" + workflowPath.toString() + "</app-path>" + " <configuration>" + " <property>" + " <name>a</name>" + " <value>A</value>" + " </property>" + " </configuration>" + "</sub-workflow>");
SubWorkflowActionExecutor subWorkflow = new SubWorkflowActionExecutor();
subWorkflow.start(new Context(workflow, action), action);
final OozieClient oozieClient = subWorkflow.getWorkflowClient(new Context(workflow, action), SubWorkflowActionExecutor.LOCAL);
waitFor(JOB_TIMEOUT, new Predicate() {
public boolean evaluate() throws Exception {
return oozieClient.getJobInfo(action.getExternalId()).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
String extId = action.getExternalId();
assertEquals(workflow.getId(), oozieClient.getJobInfo(extId).getParentId());
assertEquals(WorkflowJob.Status.SUCCEEDED, oozieClient.getJobInfo(extId).getStatus());
WorkflowActionBean action1 = new WorkflowActionBean();
action1.setId(action.getId());
action1.setName(action.getName());
action1.setConf("<sub-workflow xmlns='uri:oozie:workflow:0.1'>" + " <app-path>wrongAppPath</app-path>" + " <configuration>" + " <property>" + " <name>a</name>" + " <value>A</value>" + " </property>" + " </configuration>" + "</sub-workflow>");
subWorkflow.start(new Context(workflow, action1), action1);
assertEquals(extId, action1.getExternalId());
assertEquals(workflow.getId(), oozieClient.getJobInfo(extId).getParentId());
subWorkflow.check(new Context(workflow, action1), action1);
assertEquals(WorkflowAction.Status.DONE, action1.getStatus());
subWorkflow.end(new Context(workflow, action1), action1);
assertEquals(WorkflowAction.Status.OK, action1.getStatus());
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestSubWorkflowActionExecutor method testSubWorkflowConfCreation.
public void testSubWorkflowConfCreation() throws Exception {
SubWorkflowActionExecutor subWorkflow = new SubWorkflowActionExecutor();
XConfiguration protoConf = getBaseProtoConf();
WorkflowJobBean workflow = createBaseWorkflow(protoConf, "W");
WorkflowActionBean action = (WorkflowActionBean) workflow.getActions().get(0);
action.setConf("<sub-workflow xmlns='uri:oozie:workflow:0.1'>" + " <app-path>hdfs://foo:9000/user/bar/workflow.xml</app-path>" + " <configuration>" + " <property>" + " <name>a</name>" + " <value>A</value>" + " </property>" + " </configuration>" + "</sub-workflow>");
OozieClient oozieClient = subWorkflow.getWorkflowClient(new Context(workflow, action), SubWorkflowActionExecutor.LOCAL);
assertNotNull(oozieClient);
oozieClient = subWorkflow.getWorkflowClient(new Context(workflow, action), "http://localhost:8080/oozie");
assertNotNull(oozieClient);
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestSubWorkflowActionExecutor method testSubWorkflowStart.
public void testSubWorkflowStart() throws Exception {
Path subWorkflowAppPath = getFsTestCaseDir();
FileSystem fs = getFileSystem();
Writer writer = new OutputStreamWriter(fs.create(new Path(subWorkflowAppPath, "workflow.xml")));
writer.write(APP1);
writer.close();
XConfiguration protoConf = getBaseProtoConf();
WorkflowJobBean workflow = createBaseWorkflow(protoConf, "W");
final WorkflowActionBean action = (WorkflowActionBean) workflow.getActions().get(0);
action.setConf("<sub-workflow xmlns='uri:oozie:workflow:0.1'>" + " <app-path>" + subWorkflowAppPath + "</app-path>" + " <configuration>" + " <property>" + " <name>a</name>" + " <value>A</value>" + " </property>" + " </configuration>" + "</sub-workflow>");
SubWorkflowActionExecutor subWorkflow = new SubWorkflowActionExecutor();
subWorkflow.start(new Context(workflow, action), action);
final OozieClient oozieClient = subWorkflow.getWorkflowClient(new Context(workflow, action), SubWorkflowActionExecutor.LOCAL);
waitFor(JOB_TIMEOUT, new Predicate() {
public boolean evaluate() throws Exception {
return oozieClient.getJobInfo(action.getExternalId()).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, oozieClient.getJobInfo(action.getExternalId()).getStatus());
subWorkflow.check(new Context(workflow, action), action);
assertEquals(WorkflowAction.Status.DONE, action.getStatus());
subWorkflow.end(new Context(workflow, action), action);
assertEquals(WorkflowAction.Status.OK, action.getStatus());
assertEquals(workflow.getId(), oozieClient.getJobInfo(action.getExternalId()).getParentId());
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestSubWorkflowActionExecutor method testParentGlobalConfWithConfigDefault.
public void testParentGlobalConfWithConfigDefault() throws Exception {
try {
Path subWorkflowAppPath = createSubWorkflowXml();
createConfigDefaultXml();
createSubWorkflowConfigDefaultXml();
String workflowUri = createTestWorkflowXml(subWorkflowAppPath);
LocalOozie.start();
final OozieClient wfClient = LocalOozie.getClient();
Properties conf = wfClient.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, workflowUri);
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("appName", "var-app-name");
conf.setProperty("foo", "other");
final String jobId = wfClient.submit(conf);
wfClient.start(jobId);
// configuration should have overridden value
assertEquals("other", new XConfiguration(new StringReader(wfClient.getJobInfo(jobId).getConf())).get("foo"));
waitFor(JOB_TIMEOUT, new Predicate() {
public boolean evaluate() throws Exception {
return (wfClient.getJobInfo(jobId).getStatus() == WorkflowJob.Status.SUCCEEDED) && (wfClient.getJobInfo(jobId).getActions().get(1).getStatus() == WorkflowAction.Status.OK);
}
});
WorkflowJob subWorkflow = wfClient.getJobInfo(wfClient.getJobInfo(jobId).getActions().get(1).getExternalId());
Configuration subWorkflowConf = getWorkflowConfig(subWorkflow);
Element eConf = XmlUtils.parseXml(subWorkflow.getActions().get(1).getConf());
Element element = eConf.getChild("configuration", eConf.getNamespace());
Configuration actionConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(element).toString()));
// configuration in subWorkflow should have overridden value
assertEquals("other", subWorkflowConf.get("foo"));
assertEquals("foo1", actionConf.get("foo1"));
assertEquals("subconf", actionConf.get("foo2"));
assertEquals("foo3", actionConf.get("foo3"));
// Checking the action conf configuration.
assertEquals("actionconf", subWorkflowConf.get("foo3"));
assertEquals("subactionconf", actionConf.get("foo4"));
// config defaults are present
assertEquals("default", subWorkflowConf.get("parentConfigDefault"));
assertEquals("default", actionConf.get("subwfConfigDefault"));
} finally {
LocalOozie.stop();
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestSshActionExecutor method testSshCheckWithInvalidXml.
/**
* test {@code SshActionExecutor.check()} method with invalid
* xml configuration
*/
public void testSshCheckWithInvalidXml() 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.check(context, action);
fail("testSshCheckWithInvalidXml expected ex error");
} catch (ActionExecutorException aex) {
// ActionExecutorException should be thrown to pass the test
assertEquals("ERR_XML_PARSE_FAILED", aex.getErrorCode());
assertEquals(ActionExecutorException.ErrorType.ERROR, aex.getErrorType());
}
}
Aggregations