Repository: oozie
Updated Branches:
  refs/heads/master 5e2b92648 -> 75312da08


OOZIE-2382 
org.apache.oozie.action.hadoop.TestPigMain.testPig_withNullExternalID is flakey 
(rkanter)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/75312da0
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/75312da0
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/75312da0

Branch: refs/heads/master
Commit: 75312da08d0e4dd6e9aa7f62806bfae9a2a6c212
Parents: 5e2b926
Author: Robert Kanter <[email protected]>
Authored: Fri Oct 2 09:44:18 2015 -0700
Committer: Robert Kanter <[email protected]>
Committed: Fri Oct 2 09:44:18 2015 -0700

----------------------------------------------------------------------
 release-log.txt                                 |  1 +
 .../apache/oozie/action/hadoop/PigTestCase.java | 30 ++++++++++++++++++++
 .../action/hadoop/TestPigActionExecutor.java    |  6 ++++
 .../apache/oozie/action/hadoop/TestPigMain.java |  1 +
 4 files changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/75312da0/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 037d4bb..30578b6 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 4.3.0 release (trunk - unreleased)
 
+OOZIE-2382 
org.apache.oozie.action.hadoop.TestPigMain.testPig_withNullExternalID is flakey 
(rkanter)
 OOZIE-2379 
org.apache.oozie.command.coord.TestCoordPushDependencyCheckXCommand.testRequeueOnException
 is flakey (rkanter)
 OOZIE-2378 org.apache.oozie.client.TestOozieCLI.testAdminInstrumentation is 
flakey (rkanter)
 OOZIE-2377 Hive2 Action should not propagate oozie.hive2.* properties to 
Beeline (rkanter)

http://git-wip-us.apache.org/repos/asf/oozie/blob/75312da0/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/PigTestCase.java
----------------------------------------------------------------------
diff --git 
a/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/PigTestCase.java 
b/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/PigTestCase.java
index a098369..2789290 100644
--- a/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/PigTestCase.java
+++ b/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/PigTestCase.java
@@ -23,6 +23,7 @@ import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Method;
 import java.util.concurrent.Callable;
 
 import org.antlr.runtime.ANTLRReaderStream;
@@ -32,6 +33,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.oozie.test.XFsTestCase;
 import org.apache.oozie.util.ClassUtils;
 import org.apache.oozie.util.IOUtils;
+import org.apache.pig.tools.pigstats.PigStats;
 import org.python.util.jython;
 
 import com.google.common.primitives.Booleans;
@@ -114,4 +116,32 @@ public abstract class PigTestCase extends XFsTestCase 
implements Callable<Void>
     }
 
 
+    /**
+     * PigStats is a singleton, so it gets persisted between unit tests that 
run different Pig jobs that run PigMain. Unfortunetly,
+     * there isn't a clean way to reset it.  Pig v 0.9 has a set method which 
we can pass null to in order to reset the PigStats.
+     * However, this was changed in Pig v 0.13 to the start method.  In either 
case, they're both package private, so we have to use
+     * reflection to find the existing method for whichever version of Pig 
we're using and make it public.
+     *
+     * This should be called when tearing down any unit test that runs PigMain.
+     *
+     * @throws Exception
+     */
+    static void resetPigStats() throws Exception {
+        Method m = null;
+        try {
+            System.out.println("Attempting to reset PigStats via 'set' 
method");
+            m = PigStats.class.getDeclaredMethod("set", PigStats.class);
+        } catch (NoSuchMethodException e1) {
+            try {
+                System.out.println("Attempting to reset PigStats via 'start' 
method");
+                m = PigStats.class.getDeclaredMethod("start", PigStats.class);
+            } catch (NoSuchMethodException e2) {
+                System.out.println("WARNING: Unable to reset PigStats. This 
may cause test failures.");
+            }
+        }
+        if (m != null) {
+            m.setAccessible(true);
+            m.invoke(null, (PigStats) null);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/oozie/blob/75312da0/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigActionExecutor.java
----------------------------------------------------------------------
diff --git 
a/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigActionExecutor.java
 
b/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigActionExecutor.java
index 4b9a4e8..27cae7b 100644
--- 
a/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigActionExecutor.java
+++ 
b/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigActionExecutor.java
@@ -81,6 +81,12 @@ public class TestPigActionExecutor extends 
ActionExecutorTestCase {
     }
 
     @Override
+    protected void tearDown() throws Exception {
+        PigTestCase.resetPigStats();
+        super.tearDown();
+    }
+
+    @Override
     protected void setSystemProps() throws Exception {
         super.setSystemProps();
         setSystemProperty("oozie.service.ActionService.executor.classes", 
PigActionExecutor.class.getName());

http://git-wip-us.apache.org/repos/asf/oozie/blob/75312da0/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigMain.java
----------------------------------------------------------------------
diff --git 
a/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigMain.java 
b/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigMain.java
index 29f7ed0..f3ade51 100644
--- a/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigMain.java
+++ b/sharelib/pig/src/test/java/org/apache/oozie/action/hadoop/TestPigMain.java
@@ -48,6 +48,7 @@ public class TestPigMain extends PigTestCase {
     @Override
     protected void tearDown() throws Exception {
         System.setSecurityManager(SECURITY_MANAGER);
+        resetPigStats();
         super.tearDown();
     }
 

Reply via email to