defaultConf.set("mapred.reducer.class", "RR");
defaultConf.set("cc", "from_default");
defaultConf.writeXml(os);
os.close();
String wfId = new SubmitXCommand(conf).call();
new StartXCommand(wfId).call();
sleep(3000);
WorkflowActionBean mrAction = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION,
wfId + "@mr-node");
// check NN and JT settings
Element eAction = XmlUtils.parseXml(mrAction.getConf());
Element eConf = eAction.getChild("name-node", eAction.getNamespace());
assertEquals(getNameNodeUri(), eConf.getText());
eConf = eAction.getChild("job-tracker", eAction.getNamespace());
assertEquals(getJobTrackerUri(), eConf.getText());
// check other m-r settings
eConf = eAction.getChild("configuration", eAction.getNamespace());
Configuration actionConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(eConf).toString()));
assertEquals("default-output-dir", actionConf.get("outputDir"));
assertEquals("MM", actionConf.get("mapred.mapper.class"));
assertEquals("RR", actionConf.get("mapred.reducer.class"));
// check that default did not overwrite same property explicit in action conf
assertEquals("from_action", actionConf.get("cc"));
// check that original conf and from global was not deleted
assertEquals("AA", actionConf.get("aa"));
assertEquals("BB", actionConf.get("bb"));
//test no infinite recursion by param referring to itself e.g. path = ${path}/sub-path
actionXml = "<map-reduce>"
+ " <prepare>"
+ " <delete path=\"${nameNode}/user/${wf:user()}/mr/${outputDir}\"/>"
+ " </prepare>"
+ " <configuration>"
+ " <property><name>cc</name><value>${cc}/action_cc</value></property>"
+ " </configuration>"
+ " </map-reduce>";
wfXml = "<workflow-app xmlns=\"uri:oozie:workflow:0.5\" name=\"map-reduce-wf\">"
+ "<global>"
+ "<job-tracker>${jobTracker}</job-tracker>"
+ "<name-node>${nameNode}</name-node>"
+ "<configuration><property><name>outputDir</name><value>global-output-dir</value></property></configuration>"
+ "</global>"
+ " <start to=\"mr-node\"/>"
+ " <action name=\"mr-node\">"
+ actionXml
+ " <ok to=\"end\"/>"
+ " <error to=\"fail\"/>"
+ "</action>"
+ "<kill name=\"fail\">"
+ " <message>Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>"
+ "</kill>"
+ "<end name=\"end\"/>"
+ "</workflow-app>";
writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
IOUtils.copyCharStream(new StringReader(wfXml), writer);
wfId = new SubmitXCommand(conf).call();
new StartXCommand(wfId).call();
sleep(3000);
mrAction = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION,
wfId + "@mr-node");