hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r986964 - in /hadoop/common/trunk: CHANGES.txt src/test/core/org/apache/hadoop/io/compress/TestCodec.java
Date Wed, 18 Aug 2010 21:57:19 GMT
Author: tomwhite
Date: Wed Aug 18 21:57:18 2010
New Revision: 986964

URL: http://svn.apache.org/viewvc?rev=986964&view=rev
Log:
HADOOP-6803. Add native gzip read/write coverage to TestCodec. Contributed by Eli Collins.

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/compress/TestCodec.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=986964&r1=986963&r2=986964&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Wed Aug 18 21:57:18 2010
@@ -122,6 +122,9 @@ Trunk (unreleased changes)
 
     HADOOP-6693. Add metrics to track kerberol login activity. (suresh)
 
+    HADOOP-6803. Add native gzip read/write coverage to TestCodec.
+    (Eli Collins via tomwhite)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/io/compress/TestCodec.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/io/compress/TestCodec.java?rev=986964&r1=986963&r2=986964&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/io/compress/TestCodec.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/io/compress/TestCodec.java Wed Aug
18 21:57:18 2010
@@ -57,6 +57,7 @@ import org.apache.hadoop.io.compress.Com
 import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor;
 import org.apache.hadoop.io.compress.zlib.BuiltInZlibDeflater;
 import org.apache.hadoop.io.compress.zlib.BuiltInZlibInflater;
+import org.apache.hadoop.io.compress.zlib.ZlibCompressor;
 import org.apache.hadoop.io.compress.zlib.ZlibCompressor.CompressionLevel;
 import org.apache.hadoop.io.compress.zlib.ZlibCompressor.CompressionStrategy;
 import org.apache.hadoop.io.compress.zlib.ZlibFactory;
@@ -629,22 +630,30 @@ public class TestCodec {
     }
   }
 
-  @Test
-  public void testGzipCodecWrite() throws IOException {
+  public void testGzipCodecWrite(boolean useNative) throws IOException {
     // Create a gzipped file using a compressor from the CodecPool,
     // and try to read it back via the regular GZIPInputStream.
 
-    // Don't use native libs for this test.
+    // Use native libs per the parameter
     Configuration conf = new Configuration();
-    conf.setBoolean(CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, false);
-    assertFalse("ZlibFactory is using native libs against request",
-        ZlibFactory.isNativeZlibLoaded(conf));
+    conf.setBoolean(CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, useNative);
+    if (useNative) {
+      if (!ZlibFactory.isNativeZlibLoaded(conf)) {
+        LOG.warn("testGzipCodecWrite skipped: native libs not loaded");
+        return;
+      }
+    } else {
+      assertFalse("ZlibFactory is using native libs against request",
+          ZlibFactory.isNativeZlibLoaded(conf));
+    }
 
     // Ensure that the CodecPool has a BuiltInZlibDeflater in it.
     Compressor zlibCompressor = ZlibFactory.getZlibCompressor(conf);
     assertNotNull("zlibCompressor is null!", zlibCompressor);
     assertTrue("ZlibFactory returned unexpected deflator",
-        zlibCompressor instanceof BuiltInZlibDeflater);
+          useNative ? zlibCompressor instanceof ZlibCompressor
+                    : zlibCompressor instanceof BuiltInZlibDeflater);
+
     CodecPool.returnCompressor(zlibCompressor);
 
     // Create a GZIP text file via the Compressor interface.
@@ -680,4 +689,14 @@ public class TestCodec {
 
     verifyGzipFile(fileName, msg);
   }
+
+  @Test
+  public void testGzipCodecWriteJava() throws IOException {
+    testGzipCodecWrite(false);
+  }
+
+  @Test
+  public void testGzipNativeCodecWrite() throws IOException {
+    testGzipCodecWrite(true);
+  }
 }



Mime
View raw message