use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class TestJavaActionExecutor method testGlobalConfigurationWithActionDefaults.
public void testGlobalConfigurationWithActionDefaults() throws Exception {
try {
String workflowUri = helper.createTestWorkflowXml(getWorkflowGlobalXml(), helper.getJavaActionXml(""));
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");
final String jobId = wfClient.submit(conf);
wfClient.start(jobId);
WorkflowJob workflow = wfClient.getJobInfo(jobId);
waitFor(20 * 1000, new Predicate() {
@Override
public boolean evaluate() throws Exception {
WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId));
return javaAction != null && !javaAction.getStatus().equals("PREP");
}
});
final WorkflowAction workflowAction = helper.getJavaAction(workflow);
Element eConf = XmlUtils.parseXml(workflowAction.getConf());
Element element = eConf.getChild("configuration", eConf.getNamespace());
Configuration actionConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(element).toString()));
assertEquals("Config value set in <global> section is not propagated correctly", "foo2", actionConf.get("action.foo"));
} finally {
LocalOozie.stop();
}
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class TestJavaActionExecutor method testResourceManagerInGlobalConfigurationCanBeOverridenWithJobTrackerInAction.
public void testResourceManagerInGlobalConfigurationCanBeOverridenWithJobTrackerInAction() throws Exception {
try {
final String global = "<global>" + "<resource-manager>RM</resource-manager>" + "</global>";
final String workflowUri = helper.createTestWorkflowXml(global, helper.getJavaActionXml(""));
LocalOozie.start();
final OozieClient wfClient = LocalOozie.getClient();
final Properties conf = wfClient.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, workflowUri);
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("appName", "var-app-name");
final String jobId = wfClient.submit(conf);
wfClient.start(jobId);
WorkflowJob workflow = wfClient.getJobInfo(jobId);
waitFor(20 * 1000, new Predicate() {
@Override
public boolean evaluate() throws Exception {
WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId));
return javaAction != null && !javaAction.getStatus().equals("PREP");
}
});
final WorkflowAction workflowAction = helper.getJavaAction(workflow);
final String actualConfig = workflowAction.getConf();
final String actualJobTrackerURI = XmlUtils.parseXml(actualConfig).getChildTextNormalize("job-tracker", null);
assertEquals(getJobTrackerUri(), actualJobTrackerURI);
} finally {
LocalOozie.stop();
}
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class TestSharelibConfigs method launchJavaActionAndValidateSharelibValues.
private void launchJavaActionAndValidateSharelibValues(String globalConfig, String localConfig, String oozieSharelibForJavaPropertyValue, String oozieSharelibPropertyValue) throws Exception {
final String workflowUri = helper.createTestWorkflowXml(globalConfig, helper.getJavaActionXml(localConfig));
final OozieClient wfClient = LocalOozie.getClient();
final Properties conf = wfClient.createConfiguration();
conf.setProperty(OozieClient.APP_PATH, workflowUri);
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("appName", "var-app-name");
conf.setProperty(OozieClient.USE_SYSTEM_LIBPATH, "true");
final String jobId = wfClient.submit(conf);
wfClient.start(jobId);
WorkflowJob workflow = wfClient.getJobInfo(jobId);
waitFor(20 * 1000, new Predicate() {
@Override
public boolean evaluate() throws Exception {
WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId));
return javaAction != null && !javaAction.getStatus().equals("PREP");
}
});
final XConfiguration actionConf = getJavaActionConfiguration(workflow);
assertThat("Configuration priorities are incorrect! Global/local configs are not overwriting each other.", actionConf.get(LauncherAM.OOZIE_LAUNCHER_SHARELIB_PROPERTY), is(oozieSharelibPropertyValue));
assertThat("Configuration priorities are incorrect! Global/local configs are not overwriting each other.", actionConf.get("oozie.action.sharelib.for.java"), is(oozieSharelibForJavaPropertyValue));
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class TestSubWorkflowActionExecutor method testParentGlobalConf.
public void testParentGlobalConf() throws Exception {
try {
Path subWorkflowAppPath = createSubWorkflowXml();
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");
final String jobId = wfClient.submit(conf);
wfClient.start(jobId);
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()));
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"));
} finally {
LocalOozie.stop();
}
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class TestSubWorkflowActionExecutor method testConfigPropagation.
public void testConfigPropagation() 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");
String defaultConf = workflow.getConf();
XConfiguration newConf = new XConfiguration(new StringReader(defaultConf));
newConf.set("abc", "xyz");
newConf.set("job_prop", "job_prop_val");
workflow.setConf(newConf.toXmlString());
final WorkflowActionBean action = (WorkflowActionBean) workflow.getActions().get(0);
action.setConf("<sub-workflow xmlns='uri:oozie:workflow:0.1' name='subwf'>" + " <app-path>" + workflowPath.toString() + "</app-path>" + " <propagate-configuration />" + " <configuration>" + " <property>" + " <name>a</name>" + " <value>A</value>" + " </property>" + " <property>" + " <name>job_prop</name>" + " <value>sub_prop_val</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());
WorkflowJob wf = oozieClient.getJobInfo(action.getExternalId());
Configuration childConf = getWorkflowConfig(wf);
assertEquals("xyz", childConf.get("abc"));
assertEquals("A", childConf.get("a"));
assertEquals("sub_prop_val", childConf.get("job_prop"));
}
Aggregations