You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ch...@apache.org on 2013/03/15 06:27:57 UTC

svn commit: r1456770 - in /pig/trunk: CHANGES.txt test/org/apache/pig/test/TestMultiQueryLocal.java

Author: cheolsoo
Date: Fri Mar 15 05:27:57 2013
New Revision: 1456770

URL: http://svn.apache.org/r1456770
Log:
PIG-3077: TestMultiQueryLocal should not write in /tmp (dreambird via cheolsoo)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/test/org/apache/pig/test/TestMultiQueryLocal.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1456770&r1=1456769&r2=1456770&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri Mar 15 05:27:57 2013
@@ -133,6 +133,8 @@ PIG-3013: BinInterSedes improve chararra
 
 BUG FIXES
 
+PIG-3077: TestMultiQueryLocal should not write in /tmp (dreambird via cheolsoo)
+
 PIG-3081: Pig progress stays at 0% for the first job in hadoop 23 (rohini)
 
 PIG-3150: e2e Scripting_5 fails in trunk (dreambird via cheolsoo)

Modified: pig/trunk/test/org/apache/pig/test/TestMultiQueryLocal.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestMultiQueryLocal.java?rev=1456770&r1=1456769&r2=1456770&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestMultiQueryLocal.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestMultiQueryLocal.java Fri Mar 15 05:27:57 2013
@@ -61,6 +61,7 @@ import org.junit.Test;
 public class TestMultiQueryLocal {
 
     private PigServer myPig;
+    private String TMP_DIR;
 
     @Before
     public void setUp() throws Exception {
@@ -68,6 +69,8 @@ public class TestMultiQueryLocal {
         context.getProperties().setProperty("opt.multiquery", ""+true);
         myPig = new PigServer(context);
         myPig.getPigContext().getProperties().setProperty("pig.usenewlogicalplan", "false");
+        myPig.getPigContext().getProperties().setProperty("pig.temp.dir", "build/test/tmp/");
+        TMP_DIR = FileLocalizer.getTemporaryPath(myPig.getPigContext()).toUri().getPath();
         deleteOutputFiles();
     }
 
@@ -88,9 +91,9 @@ public class TestMultiQueryLocal {
             myPig.registerQuery("a = load 'test/org/apache/pig/test/data/passwd' " +
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("b = filter a by uid > 5;");
-            myPig.registerQuery("store b into '/tmp/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
             myPig.registerQuery("c = group b by gid;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
 
             LogicalPlan lp = checkLogicalPlan(1, 2, 5);
 
@@ -134,9 +137,9 @@ public class TestMultiQueryLocal {
             myPig.registerQuery("a = load 'test/org/apache/pig/test/data/passwd' " +
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("b = filter a by uid > 5;");
-            myPig.registerQuery("store b into '/tmp/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
             myPig.registerQuery("c = group b by gid;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
 
             myPig.executeBatch();
 
@@ -160,10 +163,10 @@ public class TestMultiQueryLocal {
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("b = filter a by uid > 5;");
             myPig.executeBatch();
-            myPig.registerQuery("store b into '/tmp/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
             myPig.executeBatch();
             myPig.registerQuery("c = group b by gid;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
 
             myPig.executeBatch();
             myPig.discardBatch();
@@ -187,11 +190,11 @@ public class TestMultiQueryLocal {
             myPig.registerQuery("a = load 'test/org/apache/pig/test/data/passwd' " +
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("b = filter a by uid > 5;");
-            myPig.registerQuery("store b into '/tmp/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
             myPig.registerQuery("c = filter b by uid > 10;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
             myPig.registerQuery("d = filter c by uid > 15;");
-            myPig.registerQuery("store d into '/tmp/Pig-TestMultiQueryLocal3';");
+            myPig.registerQuery("store d into '" + TMP_DIR + "/Pig-TestMultiQueryLocal3';");
 
             LogicalPlan lp = checkLogicalPlan(1, 3, 7);
 
@@ -218,11 +221,11 @@ public class TestMultiQueryLocal {
             myPig.registerQuery("a = load 'test/org/apache/pig/test/data/passwd' " +
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("b = filter a by uid > 5;");
-            myPig.registerQuery("store b into '/tmp/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
             myPig.registerQuery("c = filter b by uid > 10;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
             myPig.registerQuery("d = filter c by uid > 15;");
-            myPig.registerQuery("store d into '/tmp/Pig-TestMultiQueryLocal3';");
+            myPig.registerQuery("store d into '" + TMP_DIR + "/Pig-TestMultiQueryLocal3';");
 
             myPig.executeBatch();
             myPig.discardBatch();
@@ -249,10 +252,10 @@ public class TestMultiQueryLocal {
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("c = filter a by uid > 5;");
             myPig.registerQuery("d = filter b by uid > 10;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal1';");
-            myPig.registerQuery("store d into '/tmp/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store d into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
             myPig.registerQuery("e = cogroup c by uid, d by uid;");
-            myPig.registerQuery("store e into '/tmp/Pig-TestMultiQueryLocal3';");
+            myPig.registerQuery("store e into '" + TMP_DIR + "/Pig-TestMultiQueryLocal3';");
 
             LogicalPlan lp = checkLogicalPlan(2, 3, 8);
 
@@ -283,10 +286,10 @@ public class TestMultiQueryLocal {
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("c = filter a by uid > 5;");
             myPig.registerQuery("d = filter b by uid > 10;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal1';");
-            myPig.registerQuery("store d into '/tmp/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store d into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
             myPig.registerQuery("e = cogroup c by uid, d by uid;");
-            myPig.registerQuery("store e into '/tmp/Pig-TestMultiQueryLocal3';");
+            myPig.registerQuery("store e into '" + TMP_DIR + "/Pig-TestMultiQueryLocal3';");
 
             myPig.executeBatch();
             myPig.discardBatch();
@@ -407,17 +410,17 @@ public class TestMultiQueryLocal {
                                 "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);");
             myPig.registerQuery("b = filter a by uid < 5;");
             myPig.registerQuery("c = filter a by uid > 5;");
-            myPig.registerQuery("store b into '/tmp/Pig-TestMultiQueryLocal1' using " + PigStorageWithConfig.class.getName() + "('a');");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal2' using " + PigStorageWithConfig.class.getName() + "('b');");
+            myPig.registerQuery("store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1' using " + PigStorageWithConfig.class.getName() + "('a');");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2' using " + PigStorageWithConfig.class.getName() + "('b');");
 
             myPig.executeBatch();
             myPig.discardBatch();
-            BufferedReader reader = new BufferedReader(new FileReader("/tmp/Pig-TestMultiQueryLocal1/part-m-00000"));
+            BufferedReader reader = new BufferedReader(new FileReader(TMP_DIR + "/Pig-TestMultiQueryLocal1/part-m-00000"));
             String line;
             while ((line = reader.readLine())!=null) {
                 Assert.assertTrue(line.endsWith("a"));
             }
-            reader = new BufferedReader(new FileReader("/tmp/Pig-TestMultiQueryLocal2/part-m-00000"));
+            reader = new BufferedReader(new FileReader(TMP_DIR + "/Pig-TestMultiQueryLocal2/part-m-00000"));
             while ((line = reader.readLine())!=null) {
                 Assert.assertTrue(line.endsWith("b"));
             }
@@ -438,7 +441,7 @@ public class TestMultiQueryLocal {
                           + "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);"
                           + "b = filter a by uid > 5;"
                           + "explain b;"
-                          + "store b into '/tmp/Pig-TestMultiQueryLocal1';\n";
+                          + "store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';\n";
             
             GruntParser parser = new GruntParser(new StringReader(script));
             parser.setInteractive(false);
@@ -463,7 +466,7 @@ public class TestMultiQueryLocal {
                           + "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);"
                           + "b = filter a by uid > 5;"
                           + "dump b;"
-                          + "store b into '/tmp/Pig-TestMultiQueryLocal1';\n";
+                          + "store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';\n";
             
             GruntParser parser = new GruntParser(new StringReader(script));
             parser.setInteractive(false);
@@ -488,7 +491,7 @@ public class TestMultiQueryLocal {
                           + "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);"
                           + "b = filter a by uid > 5;"
                           + "describe b;"
-                          + "store b into '/tmp/Pig-TestMultiQueryLocal1';\n";
+                          + "store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';\n";
             
             GruntParser parser = new GruntParser(new StringReader(script));
             parser.setInteractive(false);
@@ -513,7 +516,7 @@ public class TestMultiQueryLocal {
                           + "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);"
                           + "b = filter a by uid > 5;"
                           + "illustrate b;"
-                          + "store b into '/tmp/Pig-TestMultiQueryLocal1';\n";
+                          + "store b into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';\n";
             
             GruntParser parser = new GruntParser(new StringReader(script));
             parser.setInteractive(false);
@@ -537,17 +540,17 @@ public class TestMultiQueryLocal {
         try {
             myPig.setBatchOn();
             myPig.registerQuery("a = load 'test/org/apache/pig/test/data/passwd';");
-            myPig.registerQuery("store a into '/tmp/Pig-TestMultiQueryLocal1' using BinStorage();");
-            myPig.registerQuery("a = load '/tmp/Pig-TestMultiQueryLocal1';");
-            myPig.registerQuery("store a into '/tmp/Pig-TestMultiQueryLocal2';");
-            myPig.registerQuery("a = load '/tmp/Pig-TestMultiQueryLocal1';");
-            myPig.registerQuery("store a into '/tmp/Pig-TestMultiQueryLocal3';");
-            myPig.registerQuery("a = load '/tmp/Pig-TestMultiQueryLocal2' using BinStorage();");
-            myPig.registerQuery("store a into '/tmp/Pig-TestMultiQueryLocal4';");
-            myPig.registerQuery("a = load '/tmp/Pig-TestMultiQueryLocal2';");
-            myPig.registerQuery("b = load '/tmp/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store a into '" + TMP_DIR + "/Pig-TestMultiQueryLocal1' using BinStorage();");
+            myPig.registerQuery("a = load '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store a into '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("a = load '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
+            myPig.registerQuery("store a into '" + TMP_DIR + "/Pig-TestMultiQueryLocal3';");
+            myPig.registerQuery("a = load '" + TMP_DIR + "/Pig-TestMultiQueryLocal2' using BinStorage();");
+            myPig.registerQuery("store a into '" + TMP_DIR + "/Pig-TestMultiQueryLocal4';");
+            myPig.registerQuery("a = load '" + TMP_DIR + "/Pig-TestMultiQueryLocal2';");
+            myPig.registerQuery("b = load '" + TMP_DIR + "/Pig-TestMultiQueryLocal1';");
             myPig.registerQuery("c = cogroup a by $0, b by $0;");
-            myPig.registerQuery("store c into '/tmp/Pig-TestMultiQueryLocal5';");
+            myPig.registerQuery("store c into '" + TMP_DIR + "/Pig-TestMultiQueryLocal5';");
 
             LogicalPlan lp = checkLogicalPlan(1, 3, 12);
             PhysicalPlan pp = checkPhysicalPlan(lp, 1, 3, 15);
@@ -555,11 +558,11 @@ public class TestMultiQueryLocal {
             myPig.executeBatch();
             myPig.discardBatch(); 
 
-            Assert.assertTrue(new File("/tmp/Pig-TestMultiQueryLocal1").exists());
-            Assert.assertTrue(new File("/tmp/Pig-TestMultiQueryLocal2").exists());
-            Assert.assertTrue(new File("/tmp/Pig-TestMultiQueryLocal3").exists());
-            Assert.assertTrue(new File("/tmp/Pig-TestMultiQueryLocal4").exists());
-            Assert.assertTrue(new File("/tmp/Pig-TestMultiQueryLocal5").exists());
+            Assert.assertTrue(new File(TMP_DIR + "/Pig-TestMultiQueryLocal1").exists());
+            Assert.assertTrue(new File(TMP_DIR + "/Pig-TestMultiQueryLocal2").exists());
+            Assert.assertTrue(new File(TMP_DIR + "/Pig-TestMultiQueryLocal3").exists());
+            Assert.assertTrue(new File(TMP_DIR + "/Pig-TestMultiQueryLocal4").exists());
+            Assert.assertTrue(new File(TMP_DIR + "/Pig-TestMultiQueryLocal5").exists());
 
             
         } catch (Exception e) {
@@ -659,11 +662,11 @@ public class TestMultiQueryLocal {
     }
 
     private void deleteOutputFiles() {
-        String outputFiles[] = { "/tmp/Pig-TestMultiQueryLocal1",
-                                 "/tmp/Pig-TestMultiQueryLocal2",
-                                 "/tmp/Pig-TestMultiQueryLocal3",
-                                 "/tmp/Pig-TestMultiQueryLocal4",
-                                 "/tmp/Pig-TestMultiQueryLocal5"
+        String outputFiles[] = { TMP_DIR + "/Pig-TestMultiQueryLocal1",
+                                 TMP_DIR + "/Pig-TestMultiQueryLocal2",
+                                 TMP_DIR + "/Pig-TestMultiQueryLocal3",
+                                 TMP_DIR + "/Pig-TestMultiQueryLocal4",
+                                 TMP_DIR + "/Pig-TestMultiQueryLocal5"
                 };
         try {
             for( String outputFile : outputFiles ) {