You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by th...@apache.org on 2010/05/07 02:24:57 UTC
svn commit: r941976 [2/3] - in /hadoop/pig/trunk: ./
test/org/apache/pig/test/ test/org/apache/pig/test/utils/
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestKeyTypeDiscoveryVisitor.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestKeyTypeDiscoveryVisitor.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestKeyTypeDiscoveryVisitor.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestKeyTypeDiscoveryVisitor.java Fri May 7 00:24:55 2010
@@ -27,8 +27,11 @@ import org.apache.pig.data.BagFactory;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.io.FileLocalizer;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import junit.framework.TestCase;
@@ -37,9 +40,10 @@ import junit.framework.TestCase;
* is correctly determines for use when the key is null. In
* particular it tests KeyTypeDiscoveryVisitor
*/
+@RunWith(JUnit4.class)
public class TestKeyTypeDiscoveryVisitor extends TestCase {
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pigServer;
TupleFactory mTf = TupleFactory.getInstance();
@@ -49,6 +53,11 @@ public class TestKeyTypeDiscoveryVisitor
public void setUp() throws Exception{
pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
}
+
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
@Test
public void testNullJoin() throws Exception {
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLargeFile.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLargeFile.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLargeFile.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLargeFile.java Fri May 7 00:24:55 2010
@@ -27,8 +27,12 @@ import org.apache.pig.data.Tuple;
import org.apache.pig.impl.io.FileLocalizer;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import junit.framework.TestCase;
import java.io.File;
@@ -44,6 +48,7 @@ import org.apache.hadoop.conf.Configurat
//Order and Distinct functions are also tested.
//This test would take a long time because of the large test files.
+@RunWith(JUnit4.class)
public class TestLargeFile extends TestCase {
File datFile;
@@ -53,7 +58,7 @@ public class TestLargeFile extends TestC
private long total = defaultBlockSize >> 1;
private int max_rand = 500;
// private double sum = 0.0, sumIn = 0.0;
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
Integer [] COUNT = new Integer[max_rand];
@@ -63,7 +68,7 @@ public class TestLargeFile extends TestC
@Override
@Before
- protected void setUp() throws Exception{
+ public void setUp() throws Exception{
System.out.println("Generating test data...");
System.out.println("Default block size = " + defaultBlockSize);
@@ -105,12 +110,16 @@ public class TestLargeFile extends TestC
@Override
@After
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
}
-
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testLargeFile () throws Exception {
System.out.println("Running testLargeFile...");
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLimitAdjuster.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLimitAdjuster.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLimitAdjuster.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLimitAdjuster.java Fri May 7 00:24:55 2010
@@ -28,6 +28,7 @@ import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.data.Tuple;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -46,6 +47,11 @@ public class TestLimitAdjuster {
public void tearDown() throws Exception {
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void simpleTest() throws Exception {
String INPUT_FILE = "input";
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLoad.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLoad.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLoad.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLoad.java Fri May 7 00:24:55 2010
@@ -60,9 +60,13 @@ import org.apache.pig.test.utils.GenPhyO
import org.apache.pig.test.utils.LogicalPlanTester;
import org.apache.pig.test.utils.TestHelper;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestLoad extends junit.framework.TestCase {
PigContext pc;
@@ -119,6 +123,11 @@ public class TestLoad extends junit.fram
assertEquals(true, size==inpDB.size());
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testLoadRemoteRel() throws Exception {
for (PigServer pig : servers) {
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLocal.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLocal.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLocal.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLocal.java Fri May 7 00:24:55 2010
@@ -50,7 +50,6 @@ public class TestLocal extends TestCase
private Log log = LogFactory.getLog(getClass());
- //MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pig;
@@ -224,7 +223,7 @@ public class TestLocal extends TestCase
try {
pig.deleteFile("frog");
} catch(Exception e) {}
-
+ tmpFile.delete();
}
@@ -277,7 +276,7 @@ public class TestLocal extends TestCase
try {
pig.deleteFile("frog");
} catch(Exception e) {}
-
+ tmpFile.delete();
}
@@ -314,6 +313,7 @@ public class TestLocal extends TestCase
}
assertEquals( MyStorage.COUNT, count );
+ tmpFile.delete();
}
@Test
@@ -352,6 +352,7 @@ public class TestLocal extends TestCase
}
assertEquals( MyStorage.COUNT, count );
+ tmpFile.delete();
}
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLocal2.java Fri May 7 00:24:55 2010
@@ -39,7 +39,6 @@ import java.util.Iterator;
public class TestLocal2 extends TestCase {
private String initString = "local";
- //MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pig ;
@@ -133,6 +132,7 @@ public class TestLocal2 extends TestCase
Iterator<Tuple> iter = pig.openIterator("C");
// Before PIG-800 was fixed this went into an infinite loop, so just
// managing to open the iterator is sufficient.
+ fp1.delete();
}
@@ -155,6 +155,7 @@ public class TestLocal2 extends TestCase
Iterator<Tuple> iter = pig.openIterator("C");
// Before PIG-800 was fixed this went into an infinite loop, so just
// managing to open the iterator is sufficient.
+ fp1.delete();
}
@@ -200,6 +201,7 @@ public class TestLocal2 extends TestCase
assertTrue(t.get(3).equals(new Integer(2)));
assertTrue(!iter.hasNext());
+ fp1.delete();
}
@@ -272,7 +274,9 @@ public class TestLocal2 extends TestCase
}
}
- return TestHelper.createTempFile(data) ;
+ File tmpFile = TestHelper.createTempFile(data) ;
+ tmpFile.deleteOnExit();
+ return tmpFile;
}
}
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLocalPOSplit.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLocalPOSplit.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLocalPOSplit.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLocalPOSplit.java Fri May 7 00:24:55 2010
@@ -134,6 +134,7 @@ public class TestLocalPOSplit extends Te
assertEquals(t.get(0), firstValue);
}
}
+ datFile.delete();
}
@Test
@@ -141,20 +142,20 @@ public class TestLocalPOSplit extends Te
init();
pigContext.connect();
- File datFile = File.createTempFile("tempN1", ".dat");
- String path1 = Util.encodeEscape(datFile.getAbsolutePath());
+ File datFile1 = File.createTempFile("tempN1", ".dat");
+ String path1 = Util.encodeEscape(datFile1.getAbsolutePath());
- FileOutputStream dat = new FileOutputStream(datFile);
+ FileOutputStream dat = new FileOutputStream(datFile1);
String s1 = "1\n2\n3\n42\n4\n5\n";
dat.write(s1.getBytes());
dat.close();
String s2 = "1\n2\n43\n3\n4\n5\n";
- datFile = File.createTempFile("tempN2", ".dat");
- String path2 = Util.encodeEscape(datFile.getAbsolutePath());
+ File datFile2 = File.createTempFile("tempN2", ".dat");
+ String path2 = Util.encodeEscape(datFile2.getAbsolutePath());
- dat = new FileOutputStream(datFile);
+ dat = new FileOutputStream(datFile2);
dat.write(s2.getBytes());
dat.close();
@@ -204,6 +205,8 @@ public class TestLocalPOSplit extends Te
for (Integer j: seen.values()) {
assertEquals(j, new Integer(2));
}
+ datFile1.delete();
+ datFile2.delete();
}
public PhysicalPlan buildPhysicalPlan(LogicalPlan lp)
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLocalRearrange.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLocalRearrange.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLocalRearrange.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLocalRearrange.java Fri May 7 00:24:55 2010
@@ -17,6 +17,8 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
@@ -31,24 +33,23 @@ import junit.framework.Assert;
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.backend.executionengine.ExecException;
-import org.apache.pig.backend.executionengine.ExecJob;
-import org.apache.pig.data.DataBag;
-import org.apache.pig.data.DataType;
-import org.apache.pig.data.DefaultTuple;
-import org.apache.pig.data.Tuple;
-import org.apache.pig.data.TupleFactory;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POLocalRearrange;
-import org.apache.pig.impl.io.NullableTuple;
+import org.apache.pig.data.DataBag;
+import org.apache.pig.data.DataType;
+import org.apache.pig.data.DefaultTuple;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.plan.PlanException;
import org.apache.pig.test.utils.GenPhyOp;
import org.apache.pig.test.utils.GenRandomData;
import org.apache.pig.test.utils.TestHelper;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -57,12 +58,13 @@ import org.junit.Test;
* group db by $0
*
*/
-public class TestLocalRearrange extends junit.framework.TestCase {
+public class TestLocalRearrange {
POLocalRearrange lr;
Tuple t;
DataBag db;
-
+ private static final MiniCluster cluster = MiniCluster.buildCluster();
+
@Before
public void setUp() throws Exception {
@@ -70,6 +72,11 @@ public class TestLocalRearrange extends
db = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
private void setUp1() throws PlanException, ExecException{
lr = GenPhyOp.topLocalRearrangeOPWithPlanPlain(0,0,db.iterator().next());
POProject proj = GenPhyOp.exprProject();
@@ -190,7 +197,6 @@ public class TestLocalRearrange extends
String INPUT_FILE = "data.txt";
- final MiniCluster cluster = MiniCluster.buildCluster();
try {
PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE));
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce.java Fri May 7 00:24:55 2010
@@ -17,6 +17,9 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
@@ -29,8 +32,6 @@ import java.util.Iterator;
import java.util.Properties;
import java.util.Map.Entry;
-import junit.framework.TestCase;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pig.EvalFunc;
@@ -49,28 +50,33 @@ import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.PigContext;
import org.apache.pig.impl.io.FileLocalizer;
import org.apache.pig.test.utils.TestHelper;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-
-public class TestMapReduce extends TestCase {
+public class TestMapReduce {
private Log log = LogFactory.getLog(getClass());
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pig;
@Before
- @Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
}
+
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testBigGroupAll() throws Throwable {
int LOOP_COUNT = 4*1024;
- File tmpFile = File.createTempFile( this.getName(), ".txt");
+ File tmpFile = File.createTempFile( this.getClass().getName(), ".txt");
PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
for(int i = 0; i < LOOP_COUNT; i++) {
ps.println(i);
@@ -85,7 +91,7 @@ public class TestMapReduce extends TestC
public void testBigGroupAllWithNull() throws Throwable {
int LOOP_COUNT = 4*1024;
- File tmpFile = File.createTempFile( this.getName(), ".txt");
+ File tmpFile = File.createTempFile(this.getClass().getName(), ".txt");
PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
long nonNullCnt = 0;
for(int i = 0; i < LOOP_COUNT; i++) {
@@ -138,7 +144,6 @@ public class TestMapReduce extends TestC
}
}
- @Test
public Double bigGroupAll( File tmpFile ) throws Throwable {
String query = "foreach (group (load '"
@@ -265,7 +270,7 @@ public class TestMapReduce extends TestC
try {
pig.deleteFile("frog");
} catch(Exception e) {}
-
+ tmpFile.delete();
}
@@ -318,7 +323,7 @@ public class TestMapReduce extends TestC
try {
pig.deleteFile("frog");
} catch(Exception e) {}
-
+ tmpFile.delete();
}
@@ -355,6 +360,7 @@ public class TestMapReduce extends TestC
}
assertEquals( MyStorage.COUNT, count );
+ tmpFile.delete();
}
@Test
@@ -393,6 +399,7 @@ public class TestMapReduce extends TestC
}
assertEquals( MyStorage.COUNT, count );
+ tmpFile.delete();
}
@@ -445,7 +452,6 @@ public class TestMapReduce extends TestC
}
- @Test
public void definedFunctions(String[][] data) throws Throwable {
File tmpFile=TestHelper.createTempFile(data) ;
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce2.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce2.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce2.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestMapReduce2.java Fri May 7 00:24:55 2010
@@ -25,16 +25,19 @@ import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.data.Tuple;
import org.apache.pig.test.utils.TestHelper;
+import org.junit.AfterClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Iterator;
-
+@RunWith(JUnit4.class)
public class TestMapReduce2 extends TestCase {
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pig ;
@@ -42,6 +45,10 @@ public class TestMapReduce2 extends Test
pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties()) ;
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
@Test
public void testUnion1() throws Exception {
@@ -170,7 +177,9 @@ public class TestMapReduce2 extends Test
}
}
- return TestHelper.createTempFile(data) ;
+ File tmpFile = TestHelper.createTempFile(data) ;
+ tmpFile.deleteOnExit();
+ return tmpFile;
}
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestMapSideCogroup.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestMapSideCogroup.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestMapSideCogroup.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestMapSideCogroup.java Fri May 7 00:24:55 2010
@@ -18,11 +18,14 @@
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.util.Iterator;
-import junit.framework.TestCase;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
@@ -48,9 +51,10 @@ import org.apache.pig.impl.logicalLayer.
import org.apache.pig.impl.logicalLayer.LogicalPlan;
import org.apache.pig.test.utils.LogicalPlanTester;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
-
-public class TestMapSideCogroup extends TestCase{
+import org.junit.Test;
+public class TestMapSideCogroup {
private static final String INPUT_FILE1 = "testCogrpInput1.txt";
private static final String INPUT_FILE2 = "testCogrpInput2.txt";
@@ -60,7 +64,7 @@ public class TestMapSideCogroup extends
private static final String EMPTY_FILE = "empty.txt";
private static final String DATA_WITH_NULL_KEYS = "null.txt";
- private MiniCluster cluster = MiniCluster.buildCluster();
+ private static MiniCluster cluster = MiniCluster.buildCluster();
@Before
public void setUp() throws Exception {
@@ -132,6 +136,12 @@ public class TestMapSideCogroup extends
Util.deleteFile(cluster, DATA_WITH_NULL_KEYS);
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
+ @Test
public void testCompilation(){
try{
LogicalPlanTester lpt = new LogicalPlanTester();
@@ -168,6 +178,7 @@ public class TestMapSideCogroup extends
}
+ @Test
public void testFailure1() throws Exception{
LogicalPlanTester lpt = new LogicalPlanTester();
lpt.buildPlan("A = LOAD 'data1' using "+ DummyCollectableLoader.class.getName() +"() as (id, name, grade);");
@@ -189,6 +200,7 @@ public class TestMapSideCogroup extends
assertTrue(exceptionCaught);
}
+ @Test
public void testFailure2() throws Exception{
LogicalPlanTester lpt = new LogicalPlanTester();
lpt.buildPlan("A = LOAD 'data1' using "+ DummyCollectableLoader.class.getName() +"() as (id, name, grade);");
@@ -208,6 +220,7 @@ public class TestMapSideCogroup extends
assertTrue(exceptionCaught);
}
+ @Test
public void testSimple() throws Exception{
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -237,6 +250,7 @@ public class TestMapSideCogroup extends
assertFalse(itr.hasNext());
}
+ @Test
public void test3Way() throws Exception{
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -270,6 +284,7 @@ public class TestMapSideCogroup extends
}
+ @Test
public void testMultiSplits() throws Exception{
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -308,6 +323,7 @@ public class TestMapSideCogroup extends
assertFalse(itr.hasNext());
}
+ @Test
public void testCogrpOnMultiKeys() throws Exception{
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -343,6 +359,7 @@ public class TestMapSideCogroup extends
assertFalse(itr.hasNext());
}
+ @Test
public void testEmptyDeltaFile() throws Exception{
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -373,7 +390,7 @@ public class TestMapSideCogroup extends
assertFalse(itr.hasNext());
}
-
+ @Test
public void testDataWithNullKeys() throws Exception{
PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoin.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoin.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoin.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoin.java Fri May 7 00:24:55 2010
@@ -46,6 +46,7 @@ import org.apache.pig.impl.util.LogUtils
import org.apache.pig.test.utils.LogicalPlanTester;
import org.apache.pig.test.utils.TestHelper;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -54,7 +55,7 @@ public class TestMergeJoin {
private static final String INPUT_FILE = "testMergeJoinInput.txt";
private static final String INPUT_FILE2 = "testMergeJoinInput2.txt";
private PigServer pigServer;
- private MiniCluster cluster = MiniCluster.buildCluster();
+ private static MiniCluster cluster = MiniCluster.buildCluster();
public TestMergeJoin() throws ExecException{
@@ -82,6 +83,10 @@ public class TestMergeJoin {
Util.createInputFile(cluster, INPUT_FILE2, new String[]{"2"});
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
/**
* @throws java.lang.Exception
*/
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoinOuter.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoinOuter.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoinOuter.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestMergeJoinOuter.java Fri May 7 00:24:55 2010
@@ -18,12 +18,15 @@
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.util.Iterator;
import java.util.Properties;
-import junit.framework.TestCase;
-
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.backend.executionengine.ExecException;
@@ -42,15 +45,16 @@ import org.apache.pig.test.TestMapSideCo
import org.apache.pig.test.TestMapSideCogroup.DummyIndexableLoader;
import org.apache.pig.test.utils.LogicalPlanTester;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.Test;
-
-public class TestMergeJoinOuter extends TestCase{
+public class TestMergeJoinOuter {
private static final String INPUT_FILE1 = "testMergeJoinInput.txt";
private static final String INPUT_FILE2 = "testMergeJoinInput2.txt";
private PigServer pigServer;
- private MiniCluster cluster = MiniCluster.buildCluster();
+ private static MiniCluster cluster = MiniCluster.buildCluster();
public TestMergeJoinOuter() throws ExecException{
@@ -60,10 +64,8 @@ public class TestMergeJoinOuter extends
pigServer = new PigServer(ExecType.MAPREDUCE, props);
}
- @Override
@Before
- protected void setUp() throws Exception {
- super.setUp();
+ public void setUp() throws Exception {
int LOOP_SIZE = 3;
String[] input = new String[LOOP_SIZE*LOOP_SIZE];
int k = 0;
@@ -77,14 +79,18 @@ public class TestMergeJoinOuter extends
Util.createInputFile(cluster, INPUT_FILE2, new String[]{"2\t2","2\t3","3\t1","4\t1","4\t3"});
}
- @Override
@After
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void tearDown() throws Exception {
Util.deleteFile(cluster, INPUT_FILE1);
Util.deleteFile(cluster, INPUT_FILE2);
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
+ @Test
public void testCompilation(){
try{
LogicalPlanTester lpt = new LogicalPlanTester();
@@ -122,6 +128,7 @@ public class TestMergeJoinOuter extends
}
+ @Test
public void testFailure() throws Exception{
LogicalPlanTester lpt = new LogicalPlanTester();
lpt.buildPlan("A = LOAD 'data1' using "+ DummyCollectableLoader.class.getName() +"() as (id, name, grade);");
@@ -142,6 +149,7 @@ public class TestMergeJoinOuter extends
assertTrue(exceptionCaught);
}
+ @Test
public void testLeftOuter() throws IOException {
pigServer.registerQuery("A = LOAD '"+INPUT_FILE1+"' using "+ DummyCollectableLoader.class.getName() +"() as (c1:chararray, c2:chararray);");
@@ -170,6 +178,7 @@ public class TestMergeJoinOuter extends
}
+ @Test
public void testRightOuter() throws IOException{
pigServer.registerQuery("A = LOAD '"+INPUT_FILE1+"' using "+ DummyCollectableLoader.class.getName() +"() as (c1:chararray, c2:chararray);");
@@ -196,6 +205,7 @@ public class TestMergeJoinOuter extends
}
+ @Test
public void testFullOuter() throws IOException{
pigServer.registerQuery("A = LOAD '"+INPUT_FILE1+"' using "+ DummyCollectableLoader.class.getName() +"() as (c1:chararray, c2:chararray);");
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestMultiQuery.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestMultiQuery.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestMultiQuery.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestMultiQuery.java Fri May 7 00:24:55 2010
@@ -75,7 +75,9 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestMultiQuery {
private static final MiniCluster cluster = MiniCluster.buildCluster();
@@ -94,6 +96,7 @@ public class TestMultiQuery {
public static void tearDownAfterClass() throws IOException {
Util.deleteFile(cluster, "passwd");
Util.deleteFile(cluster, "passwd2");
+ cluster.shutDown();
}
@Before
@@ -411,6 +414,11 @@ public class TestMultiQuery {
}
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testMultiQueryJiraPig1108() {
try {
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestNullConstant.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestNullConstant.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestNullConstant.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestNullConstant.java Fri May 7 00:24:55 2010
@@ -31,16 +31,17 @@ import org.apache.pig.PigServer;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.Tuple;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
-/**
- *
- */
+@RunWith(JUnit4.class)
public class TestNullConstant extends TestCase {
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pigServer;
@Before
@@ -49,6 +50,11 @@ public class TestNullConstant extends Te
pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testArithExpressions() throws IOException, ExecException {
String inputFileName = "testArithExpressions-input.txt";
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestOrderBy.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestOrderBy.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestOrderBy.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestOrderBy.java Fri May 7 00:24:55 2010
@@ -25,17 +25,23 @@ import java.util.Iterator;
import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
+@RunWith(JUnit4.class)
public class TestOrderBy extends TestCase {
private static final int DATALEN = 1024;
private String[][] DATA = new String[2][DATALEN];
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pig;
private File tmpFile;
@@ -49,7 +55,8 @@ public class TestOrderBy extends TestCas
pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
}
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
tmpFile = File.createTempFile("test", "txt");
PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
for(int i = 0; i < DATALEN; i++) {
@@ -58,10 +65,16 @@ public class TestOrderBy extends TestCas
ps.close();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
tmpFile.delete();
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
private void verify(String query, boolean descending) throws Exception {
pig.registerQuery(query);
Iterator<Tuple> it = pig.openIterator("myid");
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPONegative.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPONegative.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPONegative.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPONegative.java Fri May 7 00:24:55 2010
@@ -34,16 +34,28 @@ import org.apache.pig.backend.hadoop.exe
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.PONegative;
import org.apache.pig.impl.plan.PlanException;
-import junit.framework.TestCase;
+import org.junit.AfterClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import junit.framework.TestCase;
+@RunWith(JUnit4.class)
public class TestPONegative extends TestCase {
DataBag bag = BagFactory.getInstance().newDefaultBag();
Random r = new Random();
TupleFactory tf = TupleFactory.getInstance();
- MiniCluster miniCluster = MiniCluster.buildCluster();
+ static MiniCluster miniCluster = MiniCluster.buildCluster();
final int MAX = 10;
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ miniCluster.shutDown();
+ }
+
+
+ @Test
public void testPONegInt () throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -69,6 +81,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegIntAndNull () throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -106,6 +119,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegLong () throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -131,6 +145,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegLongAndNull () throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -168,6 +183,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegDouble() throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -193,6 +209,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegDoubleAndNull() throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -229,6 +246,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegFloat() throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -254,6 +272,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegFloatAndNull() throws PlanException, ExecException {
for(int i = 0; i < MAX; i++) {
Tuple t = tf.newTuple();
@@ -290,6 +309,7 @@ public class TestPONegative extends Test
}
}
+ @Test
public void testPONegType() throws Exception {
PigServer pig = new PigServer(ExecType.MAPREDUCE, miniCluster.getProperties());
File f = Util.createInputFile("tmp", "", new String[] {"a", "b", "c"});
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestParser.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestParser.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestParser.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestParser.java Fri May 7 00:24:55 2010
@@ -31,20 +31,25 @@ import org.apache.pig.PigServer;
import org.apache.pig.ExecType;
import org.apache.pig.backend.executionengine.ExecException;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestParser extends TestCase {
protected final Log log = LogFactory.getLog(getClass());
protected ExecType execType = MAPREDUCE;
- private MiniCluster cluster;
+ private static MiniCluster cluster;
protected PigServer pigServer;
@Before
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
String execTypeString = System.getProperty("test.exectype");
if(execTypeString!=null && execTypeString.length()>0){
@@ -59,11 +64,17 @@ protected final Log log = LogFactory.get
}
@After
- @Override
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
pigServer.shutdown();
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ if(cluster != null)
+ cluster.shutDown();
+ }
+
+ @Test
public void testLoadingNonexistentFile() throws ExecException, IOException {
try {
// FIXME : this should be tested in all modes
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPi.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPi.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPi.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPi.java Fri May 7 00:24:55 2010
@@ -29,8 +29,12 @@ import org.apache.pig.impl.io.FileLocali
import org.apache.pig.backend.executionengine.ExecException;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import junit.framework.TestCase;
import java.io.File;
@@ -45,6 +49,7 @@ import org.apache.hadoop.conf.Configurat
/*
* Testcase aimed at testing pig with large file sizes and filter and group functions
*/
+@RunWith(JUnit4.class)
public class TestPi extends TestCase {
private final Log log = LogFactory.getLog(getClass());
@@ -54,7 +59,7 @@ public class TestPi extends TestCase {
private long total = ((defaultBlockSize >> 20) / 10) << 20;
private int inCircle = 0;
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private long totalLength = 0, totalLengthTest = 0;
@@ -65,7 +70,7 @@ public class TestPi extends TestCase {
@Override
@Before
- protected void setUp() throws Exception{
+ public void setUp() throws Exception{
log.info("Generating test data...");
log.info("Default block size = " + defaultBlockSize);
@@ -116,10 +121,15 @@ public class TestPi extends TestCase {
@Override
@After
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testPi () throws Exception {
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPigContext.java Fri May 7 00:24:55 2010
@@ -40,9 +40,14 @@ import org.apache.pig.data.Tuple;
import org.apache.pig.impl.PigContext;
import org.apache.pig.impl.io.FileLocalizer;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestPigContext extends TestCase {
private static final String TMP_DIR_PROP = "/tmp/hadoop-hadoop";
@@ -51,11 +56,16 @@ public class TestPigContext extends Test
private File input;
private PigContext pigContext;
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = null;
+
+ @BeforeClass
+ public static void oneTimeSetup(){
+ cluster = MiniCluster.buildCluster();
+ }
@Before
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
pigContext = new PigContext(ExecType.LOCAL, getProperties());
input = File.createTempFile("PigContextTest-", ".txt");
}
@@ -199,10 +209,16 @@ public class TestPigContext extends Test
@After
@Override
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
input.delete();
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
+
private static Properties getProperties() {
Properties props = new Properties();
props.put("mapred.job.tracker", JOB_TRACKER);
@@ -226,7 +242,9 @@ public class TestPigContext extends Test
for (final String command : commands) {
pigServer.registerQuery(command);
}
- pigServer.store("counts", input.getAbsolutePath() + ".out");
+ String outFile = input.getAbsolutePath() + ".out";
+ pigServer.store("counts", outFile);
+ Util.deleteFile(cluster, outFile);
}
private void check_asserts(PigServer pigServer) {
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPigServer.java Fri May 7 00:24:55 2010
@@ -40,15 +40,19 @@ import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
-import junit.framework.TestCase;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import junit.framework.TestCase;
+@RunWith(JUnit4.class)
public class TestPigServer extends TestCase {
private PigServer pig = null;
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private File stdOutRedirectedFile;
@Before
@@ -72,6 +76,10 @@ public class TestPigServer extends TestC
stdOutRedirectedFile.delete();
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
private final static String FILE_SEPARATOR = System.getProperty("file.separator");
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPigSplit.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPigSplit.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPigSplit.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPigSplit.java Fri May 7 00:24:55 2010
@@ -54,7 +54,7 @@ public class TestPigSplit extends PigExe
* @see org.apache.pig.test.PigExecTestCase#tearDown()
*/
@Override
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
if(execType == ExecType.MAPREDUCE) {
Util.deleteFile(cluster, inputFileName);
} else if (execType == ExecType.LOCAL) {
@@ -64,7 +64,6 @@ public class TestPigSplit extends PigExe
}
}
- @Test
public void notestLongEvalSpec() throws Exception{
inputFileName = "notestLongEvalSpec-input.txt";
createInput(new String[] {"0\ta"});
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPigStorage.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPigStorage.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPigStorage.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPigStorage.java Fri May 7 00:24:55 2010
@@ -39,9 +39,12 @@ import org.apache.pig.backend.executione
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.io.FileLocalizer;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestPigStorage {
protected final Log log = LogFactory.getLog(getClass());
@@ -56,6 +59,10 @@ public class TestPigStorage {
FileLocalizer.setInitialized(false);
}
+ @AfterClass
+ public static void shutdown() {
+ cluster.shutDown();
+ }
@Test
public void testBlockBoundary() throws ExecException {
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPoissonSampleLoader.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPoissonSampleLoader.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPoissonSampleLoader.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPoissonSampleLoader.java Fri May 7 00:24:55 2010
@@ -18,31 +18,31 @@
package org.apache.pig.test;
-import java.io.*;
-import java.util.ArrayList;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.util.Iterator;
import junit.framework.TestCase;
import org.apache.pig.ExecType;
-import org.apache.pig.FuncSpec;
import org.apache.pig.PigServer;
import org.apache.pig.backend.executionengine.ExecException;
-import org.apache.pig.builtin.PigStorage;
import org.apache.pig.data.Tuple;
-import org.apache.pig.impl.builtin.PoissonSampleLoader;
-import org.apache.pig.impl.util.Pair;
-import org.apache.pig.impl.io.FileSpec;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
-
+@RunWith(JUnit4.class)
public class TestPoissonSampleLoader extends TestCase{
private static final String INPUT_FILE1 = "SkewedJoinInput1.txt";
private PigServer pigServer;
- private MiniCluster cluster = MiniCluster.buildCluster();
+ private static MiniCluster cluster = MiniCluster.buildCluster();
public TestPoissonSampleLoader() throws ExecException, IOException{
pigServer = new PigServer(ExecType.LOCAL, cluster.getProperties());
@@ -58,6 +58,11 @@ public class TestPoissonSampleLoader ext
public void setUp() throws Exception {
createFiles();
}
+
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
private void createFiles() throws IOException {
PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE1));
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestProject.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestProject.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestProject.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestProject.java Fri May 7 00:24:55 2010
@@ -38,8 +38,11 @@ import org.apache.pig.test.utils.GenPhyO
import org.apache.pig.test.utils.GenRandomData;
import org.apache.pig.test.utils.TestHelper;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
public class TestProject extends junit.framework.TestCase {
Random r;
@@ -64,7 +67,7 @@ public class TestProject extends junit.
@After
public void tearDown() throws Exception {
}
-
+
@Test
public void testGetNext() throws ExecException, IOException {
t=tRandom;
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumn.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumn.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumn.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumn.java Fri May 7 00:24:55 2010
@@ -39,13 +39,13 @@ import org.apache.pig.builtin.PigStorage
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.logicalLayer.FrontendException;
import org.apache.pig.impl.logicalLayer.optimizer.PruneColumns;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
public class TestPruneColumn extends TestCase {
- //MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pigServer;
File tmpFile1;
File tmpFile2;
@@ -170,6 +170,22 @@ public class TestPruneColumn extends Tes
}
+ @After
+ @Override
+ public void tearDown() throws Exception{
+ tmpFile1.delete();
+ tmpFile2.delete();
+ tmpFile3.delete();
+ tmpFile4.delete();
+ tmpFile5.delete();
+ tmpFile6.delete();
+ tmpFile7.delete();
+ tmpFile8.delete();
+ tmpFile9.delete();
+ tmpFile10.delete();
+ logFile.delete();
+ }
+
public boolean checkLogFileMessage(String[] messages)
{
BufferedReader reader = null;
@@ -1331,8 +1347,6 @@ public class TestPruneColumn extends Tes
assertTrue(checkLogFileMessage(new String[]{"Columns pruned for A: $1, $2",
"No map keys pruned for A"}));
-
- intermediateFile.delete();
}
@Test
@@ -1368,7 +1382,6 @@ public class TestPruneColumn extends Tes
assertTrue(checkLogFileMessage(new String[]{"Columns pruned for A: $1",
"No map keys pruned for A"}));
- intermediateFile.delete();
}
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumnNewLogicalPlan.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumnNewLogicalPlan.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumnNewLogicalPlan.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestPruneColumnNewLogicalPlan.java Fri May 7 00:24:55 2010
@@ -41,13 +41,13 @@ import org.apache.pig.data.Tuple;
import org.apache.pig.experimental.plan.optimizer.Rule;
import org.apache.pig.impl.logicalLayer.FrontendException;
import org.apache.pig.impl.logicalLayer.optimizer.PruneColumns;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
public class TestPruneColumnNewLogicalPlan extends TestCase {
- //MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pigServer;
File tmpFile1;
File tmpFile2;
@@ -174,6 +174,24 @@ public class TestPruneColumnNewLogicalPl
}
+
+ @After
+ @Override
+ public void tearDown() throws Exception{
+ tmpFile1.delete();
+ tmpFile2.delete();
+ tmpFile3.delete();
+ tmpFile4.delete();
+ tmpFile5.delete();
+ tmpFile6.delete();
+ tmpFile7.delete();
+ tmpFile8.delete();
+ tmpFile9.delete();
+ tmpFile10.delete();
+ logFile.delete();
+ }
+
+
public boolean checkLogFileMessage(String[] messages)
{
BufferedReader reader = null;
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestRelationToExprProject.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestRelationToExprProject.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestRelationToExprProject.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestRelationToExprProject.java Fri May 7 00:24:55 2010
@@ -33,8 +33,11 @@ import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.logicalLayer.parser.ParseException;
import org.apache.pig.impl.util.LogUtils;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import junit.framework.TestCase;
@@ -55,9 +58,10 @@ import junit.framework.TestCase;
* a = load 'baginp.txt' as (b:bag{t:tuple()}); b = foreach a generate $0; dump b;
* will go through a regular project (without the following flag)
*/
+@RunWith(JUnit4.class)
public class TestRelationToExprProject extends TestCase {
- private MiniCluster cluster = MiniCluster.buildCluster();
+ private static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pigServer;
private static final String TEST_FILTER_COUNT3_INPUT="test/org/apache/pig/test/data/TestRelationToExprProjectInput.txt";
@@ -65,7 +69,7 @@ public class TestRelationToExprProject e
* @see junit.framework.TestCase#setUp()
*/
@Before
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
pigServer = new PigServer(MAPREDUCE, cluster.getProperties());
}
@@ -73,10 +77,15 @@ public class TestRelationToExprProject e
* @see junit.framework.TestCase#tearDown()
*/
@After
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
pigServer.shutdown();
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
// based on the script provided in the jira issue:PIG-514
// tests that when a filter inside a foreach filters away all tuples
// for a group, an empty bag is still provided to udfs whose
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestSample.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestSample.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestSample.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestSample.java Fri May 7 00:24:55 2010
@@ -17,38 +17,33 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.text.DecimalFormat;
import java.util.Iterator;
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
-import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
-
-public class TestSample
-extends TestCase
-{
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+public class TestSample {
private PigServer pig;
private File tmpFile;
private String tmpfilepath;
private int DATALEN = 1024;
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
- @Override
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
- tmpFile = File.createTempFile( this.getName(), ".txt");
+ tmpFile = File.createTempFile( this.getClass().getName(), ".txt");
String input[] = new String[DATALEN];
for(int i = 0; i < DATALEN; i++) {
input[i] = Integer.toString(i);
@@ -58,11 +53,17 @@ extends TestCase
Util.createInputFile(cluster, tmpfilepath, input);
}
- protected void tearDown()
+ @After
+ public void tearDown()
throws Exception
{
Util.deleteFile(cluster, tmpfilepath);
}
+
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
private void verify(String query, int expected_min, int expected_max)
throws Exception
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestSampleOptimizer.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestSampleOptimizer.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestSampleOptimizer.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestSampleOptimizer.java Fri May 7 00:24:55 2010
@@ -39,8 +39,12 @@ import org.apache.pig.data.Tuple;
import org.apache.pig.impl.PigContext;
import org.apache.pig.impl.logicalLayer.LogicalPlan;
import org.apache.pig.test.utils.LogicalPlanTester;
+import org.junit.AfterClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestSampleOptimizer {
static PigContext pc;
@@ -53,6 +57,11 @@ public class TestSampleOptimizer {
}
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ MiniCluster.buildCluster().shutDown();
+ }
+
@Test
public void testOptimizerFired() throws Exception{
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestSchema.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestSchema.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestSchema.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestSchema.java Fri May 7 00:24:55 2010
@@ -655,5 +655,6 @@ public class TestSchema extends TestCase
Tuple t = it.next();
assertEquals("{a: {f1: chararray,f2: int}}", t.get(0));
}
+ cluster.shutDown();
}
}
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestSecondarySort.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestSecondarySort.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestSecondarySort.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestSecondarySort.java Fri May 7 00:24:55 2010
@@ -38,10 +38,15 @@ import org.apache.pig.impl.PigContext;
import org.apache.pig.impl.io.FileLocalizer;
import org.apache.pig.impl.logicalLayer.LogicalPlan;
import org.apache.pig.test.utils.LogicalPlanTester;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestSecondarySort extends TestCase {
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pigServer;
static PigContext pc;
@@ -54,6 +59,11 @@ public class TestSecondarySort extends T
}
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Before
@Override
public void setUp() throws Exception{
@@ -61,6 +71,7 @@ public class TestSecondarySort extends T
pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
}
+ @Test
public void testDistinctOptimization1() throws Exception{
// Limit in the foreach plan
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -81,6 +92,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testDistinctOptimization2() throws Exception{
// Distinct on one entire input
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -100,6 +112,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testDistinctOptimization3() throws Exception{
// Distinct on the prefix of main sort key
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -119,6 +132,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testDistinctOptimization4() throws Exception{
// Distinct on secondary key again, should remove
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -138,6 +152,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==2);
}
+ @Test
public void testDistinctOptimization5() throws Exception{
// Filter in foreach plan
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -157,6 +172,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testDistinctOptimization6() throws Exception{
// group by * with no schema, and distinct key is not part of main key
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -176,6 +192,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testDistinctOptimization7() throws Exception{
// group by * with no schema, distinct key is more specific than the main key
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -195,6 +212,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testDistinctOptimization8() throws Exception{
// local arrange plan is an expression
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -214,6 +232,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testDistinctOptimization9() throws Exception{
// local arrange plan is nested project
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -233,6 +252,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==1);
}
+ @Test
public void testSortOptimization1() throws Exception{
// Sort on something other than the main key
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -252,6 +272,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==0);
}
+ @Test
public void testSortOptimization2() throws Exception{
// Sort on the prefix of the main key
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -271,6 +292,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==0);
}
+ @Test
public void testSortOptimization3() throws Exception{
// Sort on the main key prefix / non main key prefix mixed
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -290,6 +312,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==0);
}
+ @Test
public void testSortOptimization4() throws Exception{
// Sort on the main key again
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -309,6 +332,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==0);
}
+ @Test
public void testSortOptimization5() throws Exception{
// Sort on the two keys, we can only take off 1
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -328,6 +352,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==0);
}
+ @Test
public void testSortOptimization6() throws Exception{
// Sort desc
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -347,6 +372,7 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==0);
}
+ @Test
public void testSortOptimization7() throws Exception{
// Sort asc on 1st key, desc on 2nd key
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -367,6 +393,7 @@ public class TestSecondarySort extends T
}
// See PIG-1193
+ @Test
public void testSortOptimization8() throws Exception{
// Sort desc, used in UDF twice
LogicalPlanTester planTester = new LogicalPlanTester() ;
@@ -386,8 +413,9 @@ public class TestSecondarySort extends T
assertTrue(so.getDistinctChanged()==0);
}
+ @Test
public void testNestedDistinctEndToEnd1() throws Exception{
- File tmpFile1 = File.createTempFile("test", "txt");
+ File tmpFile1 = Util.createTempFileDelOnExit("test", "txt");
PrintStream ps1 = new PrintStream(new FileOutputStream(tmpFile1));
ps1.println("1\t2\t3");
ps1.println("1\t3\t4");
@@ -397,7 +425,7 @@ public class TestSecondarySort extends T
ps1.println("2\t3\t4");
ps1.close();
- File tmpFile2 = File.createTempFile("test", "txt");
+ File tmpFile2 = Util.createTempFileDelOnExit("test", "txt");
PrintStream ps2 = new PrintStream(new FileOutputStream(tmpFile2));
ps2.println("1\t4\t4");
ps2.println("2\t3\t1");
@@ -420,9 +448,10 @@ public class TestSecondarySort extends T
Util.deleteFile(cluster, tmpFile1.getCanonicalPath());
Util.deleteFile(cluster, tmpFile2.getCanonicalPath());
}
-
+
+ @Test
public void testNestedDistinctEndToEnd2() throws Exception{
- File tmpFile1 = File.createTempFile("test", "txt");
+ File tmpFile1 = Util.createTempFileDelOnExit("test", "txt");
PrintStream ps1 = new PrintStream(new FileOutputStream(tmpFile1));
ps1.println("1\t2\t3");
ps1.println("1\t3\t4");
@@ -445,8 +474,9 @@ public class TestSecondarySort extends T
Util.deleteFile(cluster, tmpFile1.getCanonicalPath());
}
+ @Test
public void testNestedSortEndToEnd1() throws Exception{
- File tmpFile1 = File.createTempFile("test", "txt");
+ File tmpFile1 = Util.createTempFileDelOnExit("test", "txt");
PrintStream ps1 = new PrintStream(new FileOutputStream(tmpFile1));
ps1.println("1\t2\t3");
ps1.println("1\t3\t4");
@@ -469,8 +499,9 @@ public class TestSecondarySort extends T
Util.deleteFile(cluster, tmpFile1.getCanonicalPath());
}
+ @Test
public void testNestedSortEndToEnd2() throws Exception{
- File tmpFile1 = File.createTempFile("test", "txt");
+ File tmpFile1 = Util.createTempFileDelOnExit("test", "txt");
PrintStream ps1 = new PrintStream(new FileOutputStream(tmpFile1));
ps1.println("1\t2\t3");
ps1.println("1\t3\t4");
@@ -493,6 +524,7 @@ public class TestSecondarySort extends T
Util.deleteFile(cluster, tmpFile1.getCanonicalPath());
}
+ @Test
public void testNestedSortMultiQueryEndToEnd1() throws Exception{
pigServer.setBatchOn();
Util.copyFromLocalToCluster(cluster,
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestSkewedJoin.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestSkewedJoin.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestSkewedJoin.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestSkewedJoin.java Fri May 7 00:24:55 2010
@@ -34,8 +34,13 @@ import org.apache.pig.data.DataBag;
import org.apache.pig.data.Tuple;
import org.apache.pig.test.utils.TestHelper;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestSkewedJoin extends TestCase{
private static final String INPUT_FILE1 = "SkewedJoinInput1.txt";
private static final String INPUT_FILE2 = "SkewedJoinInput2.txt";
@@ -46,7 +51,7 @@ public class TestSkewedJoin extends Test
private static final String INPUT_FILE7 = "SkewedJoinInput7.txt";
private PigServer pigServer;
- private MiniCluster cluster = MiniCluster.buildCluster();
+ private static MiniCluster cluster = MiniCluster.buildCluster();
public TestSkewedJoin() throws ExecException, IOException{
pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -60,6 +65,11 @@ public class TestSkewedJoin extends Test
createFiles();
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
private void createFiles() throws IOException {
PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE1));
@@ -163,6 +173,7 @@ public class TestSkewedJoin extends Test
Util.deleteFile(cluster, INPUT_FILE7);
}
+ @Test
public void testSkewedJoinWithGroup() throws IOException{
pigServer.registerQuery("A = LOAD '" + INPUT_FILE1 + "' as (id, name, n);");
pigServer.registerQuery("B = LOAD '" + INPUT_FILE2 + "' as (id, name);");
@@ -188,8 +199,9 @@ public class TestSkewedJoin extends Test
}
Assert.assertTrue(dbfrj.size()>0 && dbshj.size()>0);
Assert.assertEquals(true, TestHelper.compareBags(dbfrj, dbshj));
- }
+ }
+ @Test
public void testSkewedJoinWithNoProperties() throws IOException{
pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -221,7 +233,8 @@ public class TestSkewedJoin extends Test
fail(e.getMessage());
}
}
-
+
+ @Test
public void testSkewedJoinReducers() throws IOException{
pigServer.registerQuery("A = LOAD '" + INPUT_FILE1 + "' as (id, name, n);");
pigServer.registerQuery("B = LOAD '" + INPUT_FILE2 + "' as (id, name);");
@@ -241,6 +254,7 @@ public class TestSkewedJoin extends Test
}
+ @Test
public void testSkewedJoin3Way() throws IOException{
pigServer.registerQuery("A = LOAD '" + INPUT_FILE1 + "' as (id, name, n);");
pigServer.registerQuery("B = LOAD '" + INPUT_FILE2 + "' as (id, name);");
@@ -262,6 +276,7 @@ public class TestSkewedJoin extends Test
fail("Should throw exception, do not support 3 way join");
}
+ @Test
public void testSkewedJoinMapKey() throws IOException{
pigServer.registerQuery("A = LOAD '" + INPUT_FILE4 + "' as (m:[]);");
pigServer.registerQuery("B = LOAD '" + INPUT_FILE4 + "' as (n:[]);");
@@ -285,6 +300,7 @@ public class TestSkewedJoin extends Test
}
+ @Test
public void testSkewedJoinKeyPartition() throws IOException {
try{
Util.deleteFile(cluster, "skewedjoin");
@@ -328,6 +344,7 @@ public class TestSkewedJoin extends Test
assertTrue(fc > 3);
}
+ @Test
public void testSkewedJoinNullKeys() throws IOException {
pigServer.registerQuery("A = LOAD '" + INPUT_FILE5 + "' as (id,name);");
pigServer.registerQuery("B = LOAD '" + INPUT_FILE5 + "' as (id,name);");
@@ -349,6 +366,7 @@ public class TestSkewedJoin extends Test
return;
}
+ @Test
public void testSkewedJoinOuter() throws IOException {
pigServer.registerQuery("A = LOAD '" + INPUT_FILE5 + "' as (id,name);");
pigServer.registerQuery("B = LOAD '" + INPUT_FILE5 + "' as (id,name);");
@@ -387,6 +405,7 @@ public class TestSkewedJoin extends Test
}
// pig 1048
+ @Test
public void testSkewedJoinOneValue() throws IOException {
pigServer.registerQuery("A = LOAD '" + INPUT_FILE3 + "' as (id,name);");
pigServer.registerQuery("B = LOAD '" + INPUT_FILE3 + "' as (id,name);");
@@ -418,6 +437,7 @@ public class TestSkewedJoin extends Test
}
+ @Test
public void testSkewedJoinManyReducers() throws IOException {
pigServer.getPigContext().getProperties().setProperty("pig.skewedjoin.reduce.maxtuple", "2");
pigServer.registerQuery("A = LOAD '" + INPUT_FILE6 + "' as (id,name);");
@@ -445,6 +465,7 @@ public class TestSkewedJoin extends Test
}
+ @Test
public void testSkewedJoinEmptyInput() throws IOException {
String LEFT_INPUT_FILE = "left.dat";
String RIGHT_INPUT_FILE = "right.dat";
@@ -482,6 +503,7 @@ public class TestSkewedJoin extends Test
Util.deleteFile(cluster, RIGHT_INPUT_FILE);
}
+ @Test
public void testRecursiveFileListing() throws IOException {
String LOCAL_INPUT_FILE = "test.dat";
String INPUT_FILE = "foo/bar/test.dat";
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestSplitStore.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestSplitStore.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestSplitStore.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestSplitStore.java Fri May 7 00:24:55 2010
@@ -29,22 +29,27 @@ import org.apache.pig.backend.executione
import org.apache.pig.impl.PigContext;
import org.apache.pig.impl.io.FileLocalizer;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import junit.framework.TestCase;
+@RunWith(JUnit4.class)
public class TestSplitStore extends TestCase{
private PigServer pig;
private PigContext pigContext;
private File tmpFile;
- private MiniCluster cluster = MiniCluster.buildCluster();
+ private static MiniCluster cluster = MiniCluster.buildCluster();
public TestSplitStore() throws ExecException, IOException{
pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
pigContext = pig.getPigContext();
int LOOP_SIZE = 20;
tmpFile = File.createTempFile("test", "txt");
+ tmpFile.deleteOnExit();
PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
for(int i = 1; i <= LOOP_SIZE; i++) {
ps.println(i);
@@ -60,6 +65,11 @@ public class TestSplitStore extends Test
public void tearDown() throws Exception {
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void test1() throws Exception{
pig.registerQuery("A = LOAD '"
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestStore.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestStore.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestStore.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestStore.java Fri May 7 00:24:55 2010
@@ -71,9 +71,13 @@ import org.apache.pig.test.utils.Logical
import org.apache.pig.test.utils.TestHelper;
import org.apache.pig.tools.pigstats.PigStats;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestStore extends junit.framework.TestCase {
POStore st;
DataBag inpDB;
@@ -114,6 +118,11 @@ public class TestStore extends junit.fra
Util.copyFromClusterToLocal(cluster, outputFileName + "/part-m-00000", outputFileName);
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
private PigStats store() throws Exception {
PhysicalPlan pp = new PhysicalPlan();
pp.add(proj);
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestStoreOld.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestStoreOld.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestStoreOld.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestStoreOld.java Fri May 7 00:24:55 2010
@@ -26,18 +26,30 @@ import org.apache.pig.PigServer;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.io.FileLocalizer;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import junit.framework.TestCase;
+@RunWith(JUnit4.class)
public class TestStoreOld extends TestCase {
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private int LOOP_COUNT = 1024;
String fileName;
String tmpFile1, tmpFile2;
PigServer pig;
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
+ @Test
public void testSingleStore() throws Exception{
pig.registerQuery("A = load " + fileName + ";");
@@ -55,6 +67,7 @@ public class TestStoreOld extends TestCa
}
}
+ @Test
public void testMultipleStore() throws Exception{
pig.registerQuery("A = load " + fileName + ";");
@@ -76,6 +89,7 @@ public class TestStoreOld extends TestCa
}
+ @Test
public void testStoreWithMultipleMRJobs() throws Exception{
pig.registerQuery("A = load " + fileName + ";");
pig.registerQuery("B = foreach (group A by $0) generate $0, SUM($1.$0);");
@@ -98,7 +112,8 @@ public class TestStoreOld extends TestCa
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
File f = File.createTempFile("tmp", "");
PrintWriter pw = new PrintWriter(f);
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestStreaming.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestStreaming.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestStreaming.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestStreaming.java Fri May 7 00:24:55 2010
@@ -35,6 +35,7 @@ import org.apache.pig.builtin.PigStreami
import org.apache.pig.PigToStream;
import org.apache.pig.impl.util.TupleFormat;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -55,6 +56,11 @@ public class TestStreaming {
pigServer = null;
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
private TupleFactory tf = DefaultTupleFactory.getInstance();
private static final String simpleEchoStreamingCommand;
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestUDFContext.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestUDFContext.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestUDFContext.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestUDFContext.java Fri May 7 00:24:55 2010
@@ -32,21 +32,30 @@ import org.apache.pig.impl.io.BufferedPo
import org.apache.pig.impl.io.FileLocalizer;
import org.apache.pig.impl.logicalLayer.schema.Schema;
import org.apache.pig.impl.util.UDFContext;
+import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import junit.framework.TestCase;
-
+@RunWith(JUnit4.class)
public class TestUDFContext extends TestCase {
static MiniCluster cluster = null;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
cluster = MiniCluster.buildCluster();
}
-
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testUDFContext() throws Exception {
Util.createInputFile(cluster, "a.txt", new String[] { "dumb" });
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestUDFReturnMap.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestUDFReturnMap.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestUDFReturnMap.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestUDFReturnMap.java Fri May 7 00:24:55 2010
@@ -31,8 +31,14 @@ import org.apache.pig.PigServer;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.io.FileLocalizer;
import org.apache.pig.test.utils.MyUDFReturnMap;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class TestUDFReturnMap extends TestCase {
static String[] ScriptStatement = {
@@ -44,7 +50,8 @@ public class TestUDFReturnMap extends Te
static MiniCluster cluster = MiniCluster.buildCluster();
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
TempScriptFile = File.createTempFile("temp_jira_851", ".pig");
FileWriter writer = new FileWriter(TempScriptFile);
for (String line : ScriptStatement) {
@@ -53,6 +60,11 @@ public class TestUDFReturnMap extends Te
writer.close();
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testUDFReturnMap_LocalMode() {
try {
@@ -100,7 +112,8 @@ public class TestUDFReturnMap extends Te
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
TempScriptFile.delete();
}
}
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestUTF8.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestUTF8.java?rev=941976&r1=941975&r2=941976&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestUTF8.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestUTF8.java Fri May 7 00:24:55 2010
@@ -26,8 +26,11 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Iterator;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
@@ -37,10 +40,10 @@ import org.apache.pig.tools.grunt.Grunt;
import org.apache.pig.tools.parameters.ParameterSubstitutionPreprocessor;
import junit.framework.TestCase;
-
+@RunWith(JUnit4.class)
public class TestUTF8 extends TestCase {
- MiniCluster cluster = MiniCluster.buildCluster();
+ static MiniCluster cluster = MiniCluster.buildCluster();
private PigServer pigServer;
@Before
@@ -49,6 +52,11 @@ public class TestUTF8 extends TestCase {
pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
}
+ @AfterClass
+ public static void oneTimeTearDown() throws Exception {
+ cluster.shutDown();
+ }
+
@Test
public void testPigStorage() throws Exception{