You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by rv...@apache.org on 2011/10/25 03:27:25 UTC

svn commit: r1188483 - in /incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest: hadoopexamples/TestHadoopExamples.groovy hadoopsmoke/TestHadoopSmoke.groovy

Author: rvs
Date: Tue Oct 25 01:27:24 2011
New Revision: 1188483

URL: http://svn.apache.org/viewvc?rev=1188483&view=rev
Log:
BIGTOP-152. TestHadoopExamples needs refactoring into a parameterized test

Modified:
    incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopexamples/TestHadoopExamples.groovy
    incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopsmoke/TestHadoopSmoke.groovy

Modified: incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopexamples/TestHadoopExamples.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopexamples/TestHadoopExamples.groovy?rev=1188483&r1=1188482&r2=1188483&view=diff
==============================================================================
--- incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopexamples/TestHadoopExamples.groovy (original)
+++ incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopexamples/TestHadoopExamples.groovy Tue Oct 25 01:27:24 2011
@@ -18,7 +18,7 @@
 
 package org.apache.bigtop.itest.hadoopexamples
 
-import org.junit.Before
+import org.junit.BeforeClass
 import static org.junit.Assert.assertNotNull
 import org.apache.bigtop.itest.shell.Shell
 import static org.junit.Assert.assertTrue
@@ -28,6 +28,11 @@ import org.apache.bigtop.itest.JarConten
 import org.apache.commons.logging.LogFactory
 import org.apache.commons.logging.Log
 
+import org.apache.bigtop.itest.junit.OrderedParameterized
+import org.junit.runners.Parameterized.Parameters
+import org.junit.runner.RunWith
+
+@RunWith(OrderedParameterized.class)
 class TestHadoopExamples {
   static private Log LOG = LogFactory.getLog(TestHadoopExamples.class);
 
@@ -52,8 +57,8 @@ class TestHadoopExamples {
   private static Configuration conf;
   private static String HADOOP_OPTIONS;
 
-  @Before
-  void setUp() {
+  @BeforeClass
+  static void setUp() {
     conf = new Configuration();
     conf.addResource('mapred-site.xml');
     HADOOP_OPTIONS =
@@ -80,9 +85,7 @@ class TestHadoopExamples {
     assertTrue("Could not create output directory", sh.getRet() == 0);
   }
 
-  def failures = [];
-
-  def examples =
+  static Map examples =
     [
         pi                :'20 10',
         wordcount         :"$EXAMPLES/text $EXAMPLES_OUT/wordcount",
@@ -95,15 +98,28 @@ class TestHadoopExamples {
         randomtextwriter  :"-Dtest.randomtextwrite.total_bytes=1073741824 $EXAMPLES_OUT/randomtextwriter"
     ];
 
+  private String testName;
+  private String testJar;
+  private String testArgs;
+
+  @Parameters
+  public static Map<String, Object[]> generateTests() {
+    Map<String, Object[]> res = [:];
+    examples.each { k, v -> res[k] = [k.toString(), v.toString()] as Object[]; }
+    return res;
+  }
+
+  public TestHadoopExamples(String name, String args) {
+    testName = name;
+    testArgs = args;
+    testJar = HADOOP_EXAMPLES_JAR;
+  }
+
   @Test
-  void testMRExamples() {
-    examples.each { testName, args ->
-      sh.exec("$hadoop jar $HADOOP_EXAMPLES_JAR $testName $HADOOP_OPTIONS $args");
-
-      if (sh.getRet()) {
-        failures.add(testName);
-      }
-    }
-    assertTrue("The following tests have failed: " + failures, failures.size() == 0);
+  void testMRExample() {
+    sh.exec("$hadoop jar $testJar $testName $HADOOP_OPTIONS $testArgs");
+
+    assertTrue("Example $testName failed", 
+               sh.getRet() == 0);
   }
 }

Modified: incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopsmoke/TestHadoopSmoke.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopsmoke/TestHadoopSmoke.groovy?rev=1188483&r1=1188482&r2=1188483&view=diff
==============================================================================
--- incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopsmoke/TestHadoopSmoke.groovy (original)
+++ incubator/bigtop/trunk/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoopsmoke/TestHadoopSmoke.groovy Tue Oct 25 01:27:24 2011
@@ -39,7 +39,7 @@ class TestHadoopSmoke {
   static String testDir      = "test.hadoopsmoke." + (new Date().getTime())
   static String nn           = (new Configuration()).get(DFSConfigKeys.FS_DEFAULT_NAME_KEY)
 
-  String cmd = "hadoop  jar ${hadoopHome}/contrib/streaming/hadoop-streaming*.jar" +
+  String cmd = "hadoop  jar ${hadoopHome}/contrib/streaming/hadoop*streaming*.jar" +
                  " -D mapred.map.tasks=1 -D mapred.reduce.tasks=1 -D mapred.job.name=Experiment "
   String cmd2 =" -input  ${testDir}/cachefile/input.txt -mapper map.sh -file map.sh -reducer cat" +
                  " -output ${testDir}/cachefile/out -verbose "