use of org.apache.oozie.client.WorkflowAction in project oozie by apache.
the class TestSharelibConfigs method getJavaActionConfiguration.
private XConfiguration getJavaActionConfiguration(WorkflowJob workflow) throws Exception {
final WorkflowAction workflowAction = helper.getJavaAction(workflow);
final Element element = XmlUtils.parseXml(workflowAction.getConf());
final String configuration = XmlUtils.prettyPrint(element.getChild("configuration", element.getNamespace())).toString();
return new XConfiguration(new StringReader(configuration));
}
use of org.apache.oozie.client.WorkflowAction in project oozie by apache.
the class TestShellActionExecutor method testShellScriptHadoopConfDir.
/**
* Test if a shell script could run successfully with {@link ShellMain#CONF_OOZIE_SHELL_SETUP_HADOOP_CONF_DIR} enabled.
*
* @throws Exception
*/
public void testShellScriptHadoopConfDir() throws Exception {
FileSystem fs = getFileSystem();
// Create the script file with canned shell command
Path script = new Path(getAppPath(), SHELL_SCRIPTNAME);
Writer w = new OutputStreamWriter(fs.create(script));
w.write(SHELL_SCRIPT_HADOOP_CONF_DIR_CONTENT);
w.write(SHELL_SCRIPT_YARN_CONF_DIR_CONTENT);
w.write(SHELL_SCRIPT_LOG4J_EXISTENCE_CHECKER);
w.write(SHELL_SCRIPT_LOG4J_CONTENT_COUNTER);
w.close();
// Create sample Shell action xml
String actionXml = "<shell>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>oozie.action.shell.setup.hadoop.conf.dir</name><value>true</value></property>" + "</configuration>" + "<exec>" + SHELL_EXEC + "</exec>" + "<argument>" + SHELL_PARAM + "</argument>" + "<argument>" + SHELL_SCRIPTNAME + "</argument>" + "<file>" + script.toString() + "#" + script.getName() + "</file>" + "<capture-output/>" + "</shell>";
// Submit and verify the job's status
WorkflowAction action = _testSubmit(actionXml, true, "");
String oozieActionConfXml = PropertiesUtils.stringToProperties(action.getData()).getProperty("OOZIE_ACTION_CONF_XML");
String hadoopConfDir = PropertiesUtils.stringToProperties(action.getData()).getProperty("HADOOP_CONF_DIR");
String yarnConfDir = PropertiesUtils.stringToProperties(action.getData()).getProperty("YARN_CONF_DIR");
String log4jExists = PropertiesUtils.stringToProperties(action.getData()).getProperty("L4J_EXISTS");
String log4jFileLineCount = PropertiesUtils.stringToProperties(action.getData()).getProperty("L4J_LC");
String log4BadAppenderCount = PropertiesUtils.stringToProperties(action.getData()).getProperty("L4J_APPENDER");
assertNotNull(oozieActionConfXml);
assertNotNull(hadoopConfDir);
String s = new File(oozieActionConfXml).getParent() + File.separator + "oozie-hadoop-conf-";
Assert.assertTrue("Expected HADOOP_CONF_DIR to start with " + s + " but was " + hadoopConfDir, hadoopConfDir.startsWith(s));
Assert.assertTrue("Expected YARN_CONF_DIR to start with " + s + " but was " + yarnConfDir, yarnConfDir.startsWith(s));
Assert.assertEquals("Expected log4j.properties file to exist", "yes", log4jExists);
Assert.assertTrue("Expected log4j.properties to have non-zero line count, but has: " + log4jFileLineCount, Integer.parseInt(log4jFileLineCount) > 0);
Assert.assertEquals("Expected log4j.properties to have no container appender references (CLA/CLRA)", 0, Integer.parseInt(log4BadAppenderCount));
}
use of org.apache.oozie.client.WorkflowAction in project oozie by apache.
the class TestShellActionExecutor method submitAction.
/**
* Submit the Shell action using Shell ActionExecutor
*
* @param context
* @return The RunningJob of the Launcher Mapper
* @throws Exception
*/
private String submitAction(Context context) throws Exception {
ShellActionExecutor ae = new ShellActionExecutor();
WorkflowAction action = context.getAction();
ae.prepareActionDir(getFileSystem(), context);
// Submit the action
ae.submitLauncher(getFileSystem(), context, action);
String jobId = action.getExternalId();
String jobTracker = action.getTrackerUri();
String consoleUrl = action.getConsoleUrl();
assertNotNull(jobId);
assertNotNull(jobTracker);
assertNotNull(consoleUrl);
return jobId;
}
use of org.apache.oozie.client.WorkflowAction in project oozie by apache.
the class TestShellActionExecutor method testEnvVar.
/**
* Test that env variable can contain '=' symbol within value
*
* @throws Exception
*/
public void testEnvVar() throws Exception {
Services.get().destroy();
Services services = new Services();
services.getConf().setInt(LauncherAMUtils.CONF_OOZIE_ACTION_MAX_OUTPUT_DATA, 8 * 1042);
services.init();
FileSystem fs = getFileSystem();
// Create the script file with canned shell command
Path script = new Path(getAppPath(), SHELL_SCRIPTNAME);
Writer w = new OutputStreamWriter(fs.create(script));
w.write(SHELL_SCRIPT_CONTENT_ENVVAR);
w.close();
String envValueHavingEqualSign = "a=b;c=d";
// Create sample shell action xml
String actionXml = "<shell>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<exec>" + SHELL_EXEC + "</exec>" + "<argument>" + SHELL_PARAM + "</argument>" + "<argument>" + SHELL_SCRIPTNAME + "</argument>" + "<argument>A</argument>" + "<argument>B</argument>" + "<env-var>var1=val1</env-var>" + "<env-var>var2=" + envValueHavingEqualSign + "</env-var>" + "<file>" + script.toString() + "#" + script.getName() + "</file>" + "<capture-output />" + "</shell>";
Context context = createContext(actionXml);
// Submit the action
final String launcherId = submitAction(context);
waitUntilYarnAppDoneAndAssertSuccess(launcherId);
ShellActionExecutor ae = new ShellActionExecutor();
WorkflowAction action = context.getAction();
ae.check(context, action);
ae.end(context, action);
// Checking action data from shell script output
assertEquals(envValueHavingEqualSign, PropertiesUtils.stringToProperties(action.getData()).getProperty("var2"));
}
use of org.apache.oozie.client.WorkflowAction in project oozie by apache.
the class WorkflowGraphHandler method fillWorkflowActions.
private Map<String, WorkflowAction> fillWorkflowActions() {
final Map<String, WorkflowAction> workflowActions = new LinkedHashMap<>();
boolean found = false;
for (final WorkflowAction wfAction : job.getActions()) {
workflowActions.put(wfAction.getName(), wfAction);
if (!found) {
switch(wfAction.getStatus()) {
case KILLED:
case ERROR:
case FAILED:
// Assuming on error the workflow eventually ends with kill node
showKill = true;
found = true;
break;
default:
// Look further
break;
}
}
}
return workflowActions;
}
Aggregations