Author: kamrul
Date: Sat Dec 10 19:35:40 2011
New Revision: 1212852

URL: http://svn.apache.org/viewvc?rev=1212852&view=rev
Log:
OOZIE-8   Variable not getting replaced with value in workflow rerun.(Mona via 
Mohammad)

Added:
    incubator/oozie/trunk/core/src/test/resources/rerun-varsub-wf.xml
Modified:
    
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java
    
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java
    incubator/oozie/trunk/release-log.txt

Modified: 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java?rev=1212852&r1=1212851&r2=1212852&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java
 (original)
+++ 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java
 Sat Dec 10 19:35:40 2011
@@ -69,7 +69,7 @@ import org.apache.oozie.workflow.lite.No
  */
 public class ReRunXCommand extends WorkflowXCommand<Void> {
     private final String jobId;
-    private final Configuration conf;
+    private Configuration conf;
     private final String authToken;
     private final Set<String> nodesToSkip = new HashSet<String>();
     public static final String TO_SKIP = "TO_SKIP";
@@ -138,6 +138,11 @@ public class ReRunXCommand extends Workf
 
             PropertiesUtils.checkDisallowedProperties(conf, 
DISALLOWED_USER_PROPERTIES);
 
+            // Resolving all variables in the job properties. This ensures the 
Hadoop Configuration semantics are preserved.
+            // The Configuration.get function within XConfiguration.resolve() 
works recursively to get the final value corresponding to a key in the map
+            // Resetting the conf to contain all the resolved values is 
necessary to ensure propagation of Oozie properties to Hadoop calls downstream
+            conf = ((XConfiguration) conf).resolve();
+
             try {
                 newWfInstance = workflowLib.createInstance(app, conf, jobId);
             }

Modified: 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java?rev=1212852&r1=1212851&r2=1212852&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java
 (original)
+++ 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java
 Sat Dec 10 19:35:40 2011
@@ -19,6 +19,7 @@ package org.apache.oozie.command.wf;
 
 import java.util.Properties;
 import java.io.File;
+import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Reader;
@@ -101,6 +102,50 @@ public class TestReRunXCommand extends X
         assertEquals(WorkflowJob.Status.SUCCEEDED, 
wfClient.getJobInfo(jobId1).getStatus());
     }
 
+    /*
+     * Test to ensure parameterized configuration variables get resolved in 
workflow rerun
+     */
+    public void testRerunVariableSub() throws IOException, 
OozieClientException {
+        Reader reader = IOUtils.getResourceAsReader("rerun-varsub-wf.xml", -1);
+        Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+        IOUtils.copyCharStream(reader, writer);
+
+        Path path = getFsTestCaseDir();
+
+        final OozieClient wfClient = LocalOozie.getClient();
+        Properties conf = wfClient.createConfiguration();
+        conf.setProperty(OozieClient.APP_PATH, getTestCaseDir() + 
File.separator + "workflow.xml");
+        conf.setProperty(OozieClient.USER_NAME, getTestUser());
+        injectKerberosInfo(conf);
+
+        conf.setProperty("nnbase", path.toString());
+        conf.setProperty("base", conf.getProperty("nnbase"));
+        // setting the variables "srcDir" and "dstDir", used as a file paths 
in the workflow, to parameterized expressions to test resolution.
+        conf.setProperty("srcDir", "${base}/p1");
+        conf.setProperty("dstDir", "${base}/p2");
+
+        final String jobId1 = wfClient.submit(conf);
+        wfClient.start(jobId1);
+
+        wfClient.kill(jobId1);
+
+        assertEquals(WorkflowJob.Status.KILLED, 
wfClient.getJobInfo(jobId1).getStatus());
+
+        // Skip executed nodes
+        getFileSystem().delete(new Path(path, "p2"), true);
+        conf.setProperty(OozieClient.RERUN_FAIL_NODES, "false");
+
+        wfClient.reRun(jobId1, conf);
+        waitFor(15 * 1000, new Predicate() {
+            public boolean evaluate() throws Exception {
+                return wfClient.getJobInfo(jobId1).getStatus() == 
WorkflowJob.Status.SUCCEEDED;
+            }
+        });
+
+        // workflow success reflects that rerun configuration contained 
correctly resolved variable values.
+        assertEquals(WorkflowJob.Status.SUCCEEDED, 
wfClient.getJobInfo(jobId1).getStatus());
+    }
+
     public void testRerunFromFailNodes() throws IOException, 
OozieClientException {
         Reader reader = IOUtils.getResourceAsReader("rerun-wf.xml", -1);
         Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");

Added: incubator/oozie/trunk/core/src/test/resources/rerun-varsub-wf.xml
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/resources/rerun-varsub-wf.xml?rev=1212852&view=auto
==============================================================================
--- incubator/oozie/trunk/core/src/test/resources/rerun-varsub-wf.xml (added)
+++ incubator/oozie/trunk/core/src/test/resources/rerun-varsub-wf.xml Sat Dec 
10 19:35:40 2011
@@ -0,0 +1,38 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<workflow-app xmlns="uri:oozie:workflow:0.3" name="rerun-wf">
+    <start to="fs1"/>
+    <action name="fs1">
+        <fs>
+            <mkdir path="${srcDir}"/>
+        </fs>
+        <ok to="fs2"/>
+        <error to="k"/>
+    </action>
+    <action name="fs2">
+        <fs>
+            <move source="${srcDir}" target="${dstDir}"/>
+        </fs>
+        <ok to="end"/>
+        <error to="k"/>
+    </action>
+    <kill name="k">
+        <message>kill</message>
+    </kill>
+    <end name="end"/>
+</workflow-app>

Modified: incubator/oozie/trunk/release-log.txt
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1212852&r1=1212851&r2=1212852&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Sat Dec 10 19:35:40 2011
@@ -1,5 +1,6 @@
 -- Oozie 3.2.0 release
 
+OOZIE-8   Variable not getting replaced with value in workflow rerun.(Mona via 
Mohammad)
 OOZIE-15  Coordinator input/output event instance should limit 1 instance. 
(Mona via Mohammad)
 OOZIE-633 Create sharelib directory for oozie.(Mohammad)
 OOZIE-625 Oozie server not starting due to missing sl4j library for 
Authenticationfilter. (tucu)


Reply via email to