OOZIE-2598 make Shell action work, fix tests Change-Id: Ibaad392c9beb7ad9dec7f59b2b49436080572257
Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/3d339c26 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/3d339c26 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/3d339c26 Branch: refs/heads/oya Commit: 3d339c26daa29cbde377005b2cf0870f9b3e8186 Parents: b584481 Author: Peter Bacsko <pbac...@cloudera.com> Authored: Wed Sep 21 17:03:06 2016 +0200 Committer: Peter Cseh <gezap...@cloudera.com> Committed: Mon Sep 26 15:25:51 2016 +0200 ---------------------------------------------------------------------- .../action/hadoop/TestShellActionExecutor.java | 5 ++-- .../java/org/apache/oozie/test/XTestCase.java | 1 + .../oozie/action/hadoop/LauncherMain.java | 25 -------------------- .../oozie/action/hadoop/MapReduceMain.java | 24 ++++++++++++++++++- 4 files changed, 26 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/3d339c26/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java b/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java index 3354b3a..a48f211 100644 --- a/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java +++ b/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java @@ -48,7 +48,7 @@ public class TestShellActionExecutor extends ActionExecutorTestCase { private static final String SHELL_EXEC = Shell.WINDOWS ? "cmd.exe" : "sh"; private static final String SHELL_PARAM = Shell.WINDOWS ? "/c" : "-c"; - private static final String SHELL_SCRIPTNAME = Shell.WINDOWS ? "script.cmd" : "script.sh"; + private static final String SHELL_SCRIPTNAME = Shell.WINDOWS ? "script.cmd" : "./script.sh"; private static final String SHELL_SCRIPT_CONTENT = Shell.WINDOWS ? "dir /s /b\necho %1 %2\necho %PATH%\ntype %0" : "ls -ltr\necho $1 $2\necho $PATH\npwd\ntype sh"; @@ -252,8 +252,7 @@ public class TestShellActionExecutor extends ActionExecutorTestCase { private WorkflowAction _testSubmit(String actionXml, boolean checkForSuccess, String capture_output) throws Exception { Context context = createContext(actionXml); - final String launcherId = submitAction(context);// Submit the - // action + final String launcherId = submitAction(context);// Submit the action waitUntilYarnAppDoneAndAssertSuccess(launcherId); Configuration conf = new XConfiguration(); http://git-wip-us.apache.org/repos/asf/oozie/blob/3d339c26/core/src/test/java/org/apache/oozie/test/XTestCase.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/test/XTestCase.java b/core/src/test/java/org/apache/oozie/test/XTestCase.java index 1299fa3..da5c5cf 100644 --- a/core/src/test/java/org/apache/oozie/test/XTestCase.java +++ b/core/src/test/java/org/apache/oozie/test/XTestCase.java @@ -1224,6 +1224,7 @@ public abstract class XTestCase extends TestCase { } } + log.info("Final state is: {0}", finalState.getValue()); assertTrue(endStateOK.isTrue()); return finalState.getValue(); } http://git-wip-us.apache.org/repos/asf/oozie/blob/3d339c26/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java ---------------------------------------------------------------------- diff --git a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java index 6955416..9b5d57d 100644 --- a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java +++ b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java @@ -41,7 +41,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.util.Shell; import org.apache.commons.lang.StringUtils; -import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.yarn.api.ApplicationClientProtocol; import org.apache.hadoop.yarn.api.protocolrecords.ApplicationsRequestScope; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; @@ -241,30 +240,6 @@ public abstract class LauncherMain { } /** - * Will run the user specified OozieActionConfigurator subclass (if one is provided) to update the action configuration. - * - * @param actionConf The action configuration to update - * @throws OozieActionConfiguratorException - */ - protected static void runConfigClass(JobConf actionConf) throws OozieActionConfiguratorException { - String configClass = actionConf.get(LauncherMapper.OOZIE_ACTION_CONFIG_CLASS); - if (configClass != null) { - try { - Class<?> klass = Class.forName(configClass); - Class<? extends OozieActionConfigurator> actionConfiguratorKlass = klass.asSubclass(OozieActionConfigurator.class); - OozieActionConfigurator actionConfigurator = actionConfiguratorKlass.newInstance(); - actionConfigurator.configure(actionConf); - } catch (ClassNotFoundException e) { - throw new OozieActionConfiguratorException("An Exception occured while instantiating the action config class", e); - } catch (InstantiationException e) { - throw new OozieActionConfiguratorException("An Exception occured while instantiating the action config class", e); - } catch (IllegalAccessException e) { - throw new OozieActionConfiguratorException("An Exception occured while instantiating the action config class", e); - } - } - } - - /** * Read action configuration passes through action xml file. * * @return action Configuration http://git-wip-us.apache.org/repos/asf/oozie/blob/3d339c26/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java ---------------------------------------------------------------------- diff --git a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java index ee5044b..b808535 100644 --- a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java +++ b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java @@ -148,5 +148,27 @@ public class MapReduceMain extends LauncherMain { } return values; } - + /** + * Will run the user specified OozieActionConfigurator subclass (if one is provided) to update the action configuration. + * + * @param actionConf The action configuration to update + * @throws OozieActionConfiguratorException + */ + private static void runConfigClass(JobConf actionConf) throws OozieActionConfiguratorException { + String configClass = actionConf.get(LauncherMapper.OOZIE_ACTION_CONFIG_CLASS); + if (configClass != null) { + try { + Class<?> klass = Class.forName(configClass); + Class<? extends OozieActionConfigurator> actionConfiguratorKlass = klass.asSubclass(OozieActionConfigurator.class); + OozieActionConfigurator actionConfigurator = actionConfiguratorKlass.newInstance(); + actionConfigurator.configure(actionConf); + } catch (ClassNotFoundException e) { + throw new OozieActionConfiguratorException("An Exception occured while instantiating the action config class", e); + } catch (InstantiationException e) { + throw new OozieActionConfiguratorException("An Exception occured while instantiating the action config class", e); + } catch (IllegalAccessException e) { + throw new OozieActionConfiguratorException("An Exception occured while instantiating the action config class", e); + } + } + } }