Author: kamrul
Date: Mon Apr 30 20:57:01 2012
New Revision: 1332384

URL: http://svn.apache.org/viewvc?rev=1332384&view=rev
Log:
OOZIE-820 Shell action to support env-var value with = sign(Mona via Mohammad)

Modified:
    
incubator/oozie/branches/branch-3.2/core/src/main/java/org/apache/oozie/action/hadoop/ShellMain.java
    
incubator/oozie/branches/branch-3.2/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
    incubator/oozie/branches/branch-3.2/release-log.txt

Modified: 
incubator/oozie/branches/branch-3.2/core/src/main/java/org/apache/oozie/action/hadoop/ShellMain.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/branches/branch-3.2/core/src/main/java/org/apache/oozie/action/hadoop/ShellMain.java?rev=1332384&r1=1332383&r2=1332384&view=diff
==============================================================================
--- 
incubator/oozie/branches/branch-3.2/core/src/main/java/org/apache/oozie/action/hadoop/ShellMain.java
 (original)
+++ 
incubator/oozie/branches/branch-3.2/core/src/main/java/org/apache/oozie/action/hadoop/ShellMain.java
 Mon Apr 30 20:57:01 2012
@@ -115,7 +115,7 @@ public class ShellMain extends LauncherM
         // Adding user-specified environments
         String[] envs = MapReduceMain.getStrings(actionConf, 
CONF_OOZIE_SHELL_ENVS);
         for (String env : envs) {
-            String[] varValue = env.split("="); // Error case is handled in
+            String[] varValue = env.split("=",2); // Error case is handled in
                                                 // ShellActionExecutor
             envp.put(varValue[0], varValue[1]);
         }

Modified: 
incubator/oozie/branches/branch-3.2/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/branches/branch-3.2/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java?rev=1332384&r1=1332383&r2=1332384&view=diff
==============================================================================
--- 
incubator/oozie/branches/branch-3.2/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
 (original)
+++ 
incubator/oozie/branches/branch-3.2/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
 Mon Apr 30 20:57:01 2012
@@ -180,6 +180,50 @@ public class TestShellActionExecutor ext
     }
 
     /**
+     * Test that env variable can contain '=' symbol within value
+     *
+     * @throws Exception
+     */
+    public void testEnvVar() throws Exception {
+
+        String shellScript = "ls -ltr\necho var1=$var1\necho var2=$var2";
+        FileSystem fs = getFileSystem();
+        // Create the script file with canned shell command
+        Path script = new Path(getAppPath(), "script.sh");
+        Writer w = new OutputStreamWriter(fs.create(script));
+        w.write(shellScript);
+        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>sh</exec>" + 
"<argument>-c</argument>"
+                + "<argument>script.sh</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 RunningJob launcherJob = submitAction(context);
+        waitFor(30 * 1000, new Predicate() { // Wait for the external job to
+                    // finish
+                    public boolean evaluate() throws Exception {
+                        return launcherJob.isComplete();
+                    }
+                });
+
+        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"));
+
+    }
+
+    /**
      * Submit the WF with a Shell action and very of the job succeeds
      *
      * @param actionXml

Modified: incubator/oozie/branches/branch-3.2/release-log.txt
URL: 
http://svn.apache.org/viewvc/incubator/oozie/branches/branch-3.2/release-log.txt?rev=1332384&r1=1332383&r2=1332384&view=diff
==============================================================================
--- incubator/oozie/branches/branch-3.2/release-log.txt (original)
+++ incubator/oozie/branches/branch-3.2/release-log.txt Mon Apr 30 20:57:01 2012
@@ -1,5 +1,6 @@
 -- Oozie 3.2.0 release
 
+OOZIE-820 Shell action to support env-var value with = sign (Mona via Mohammad)
 OOZIE-825 Update oozie-sharelib-hive to use Hive 0.9.0 (virag via tucu)
 OOZIE-813 Sub-workflow child job does not get group name even if parent 
carries.(Mona via Mohammad)
 OOZIE-791 coord job status not updated to done_with_error after kill(Virag via 
Mohammad)


Reply via email to