You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by sc...@apache.org on 2012/09/28 20:37:17 UTC

svn commit: r1391585 - /incubator/bigtop/branches/branch-0.3.1/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadooptests/TestTextSnappy.groovy

Author: schu
Date: Fri Sep 28 18:37:17 2012
New Revision: 1391585

URL: http://svn.apache.org/viewvc?rev=1391585&view=rev
Log:
BIGTOP-719: Add TestTextSnappy to test hadoop fs -text with snappy compressed files

Added:
    incubator/bigtop/branches/branch-0.3.1/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadooptests/TestTextSnappy.groovy

Added: incubator/bigtop/branches/branch-0.3.1/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadooptests/TestTextSnappy.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/branches/branch-0.3.1/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadooptests/TestTextSnappy.groovy?rev=1391585&view=auto
==============================================================================
--- incubator/bigtop/branches/branch-0.3.1/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadooptests/TestTextSnappy.groovy (added)
+++ incubator/bigtop/branches/branch-0.3.1/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadooptests/TestTextSnappy.groovy Fri Sep 28 18:37:17 2012
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bigtop.itest.hadooptests
+
+import org.apache.bigtop.itest.shell.Shell
+import org.junit.AfterClass
+import org.junit.BeforeClass
+import org.junit.Test
+import static org.junit.Assert.assertEquals
+
+class TestTextSnappy {
+  static Shell sh = new Shell("/bin/bash -s")
+  static String testDir = "testtextsnappy." + (new Date().getTime())
+  static String snappyFile = "part-00001.snappy"
+
+  @BeforeClass
+  static void  setUp() throws IOException {
+    sh.exec(
+    "hadoop fs  -mkdir ${testDir}",
+    "hadoop fs -put ${snappyFile} ${testDir}/${snappyFile}",
+    )
+    logError(sh)
+  }
+
+  @AfterClass
+  static void tearDown() {
+    sh.exec("hadoop fs -rmr -skipTrash ${testDir}")
+  }
+
+  @Test
+  void testTextSnappy() {
+    String cmd = "hadoop fs -text ${testDir}/${snappyFile}"
+    System.out.println(cmd)
+    sh.exec(cmd)
+    String output = sh.getOut().join("\n")
+    logError(sh)
+    String expected = "1\trafferty\t31\n2\tjones\t33\n3\tsteinberg\t33"
+    System.out.println("Expected output:\n${expected}")
+    System.out.println("Actual output:\n${output}")
+    assertEquals("Incorrect output", output, expected)
+  }
+
+  private static void logError (final Shell sh) {
+    if (sh.getRet()) {
+      println ('Failed command: ' + sh.script);
+      println ('\terror code: ' + sh.getRet());
+      println ('\tstdout: ' + sh.getOut());
+      println ('\tstderr: ' + sh.getErr());
+    }
+  }
+}