diff --git a/CHANGES.txt b/CHANGES.txt index f63b1554ad..637a308577 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/src/test/core/org/apache/hadoop/io/compress/TestCodec.java b/src/test/core/org/apache/hadoop/io/compress/TestCodec.java index d259d8b4f0..9b2435a0a1 100644 --- a/src/test/core/org/apache/hadoop/io/compress/TestCodec.java +++ b/src/test/core/org/apache/hadoop/io/compress/TestCodec.java @@ -57,6 +57,7 @@ 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 @@ private void verifyGzipFile(String filename, String msg) throws IOException { } } - @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 void testGzipCodecWrite() throws IOException { verifyGzipFile(fileName, msg); } + + @Test + public void testGzipCodecWriteJava() throws IOException { + testGzipCodecWrite(false); + } + + @Test + public void testGzipNativeCodecWrite() throws IOException { + testGzipCodecWrite(true); + } }