HADOOP-8537. Fix TFile tests to pass even when native zlib support is not compiled. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1362730 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-07-18 00:51:36 +00:00
parent c22cddbad1
commit 1aa9249c61
2 changed files with 8 additions and 4 deletions

View File

@ -158,6 +158,9 @@ Release 2.0.1-alpha - UNRELEASED
HADOOP-8552. Conflict: Same security.log.file for multiple users. HADOOP-8552. Conflict: Same security.log.file for multiple users.
(kkambatl via tucu) (kkambatl via tucu)
HADOOP-8537. Fix TFile tests to pass even when native zlib support is not
compiled. (todd)
BREAKDOWN OF HDFS-3042 SUBTASKS BREAKDOWN OF HDFS-3042 SUBTASKS
HADOOP-8220. ZKFailoverController doesn't handle failure to become active HADOOP-8220. ZKFailoverController doesn't handle failure to become active

View File

@ -30,6 +30,7 @@ import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.WritableUtils; import org.apache.hadoop.io.WritableUtils;
import org.apache.hadoop.io.compress.zlib.ZlibFactory;
import org.apache.hadoop.io.file.tfile.TFile.Reader; import org.apache.hadoop.io.file.tfile.TFile.Reader;
import org.apache.hadoop.io.file.tfile.TFile.Writer; import org.apache.hadoop.io.file.tfile.TFile.Writer;
import org.apache.hadoop.io.file.tfile.TFile.Reader.Location; import org.apache.hadoop.io.file.tfile.TFile.Reader.Location;
@ -57,7 +58,7 @@ public class TestTFileByteArrays {
private static final String VALUE = "value"; private static final String VALUE = "value";
private FileSystem fs; private FileSystem fs;
private Configuration conf; private Configuration conf = new Configuration();
private Path path; private Path path;
private FSDataOutputStream out; private FSDataOutputStream out;
private Writer writer; private Writer writer;
@ -71,8 +72,9 @@ public class TestTFileByteArrays {
* generated key and value strings. This is slightly different based on * generated key and value strings. This is slightly different based on
* whether or not the native libs are present. * whether or not the native libs are present.
*/ */
private int records1stBlock = NativeCodeLoader.isNativeCodeLoaded() ? 5674 : 4480; private boolean usingNative = ZlibFactory.isNativeZlibLoaded(conf);
private int records2ndBlock = NativeCodeLoader.isNativeCodeLoaded() ? 5574 : 4263; private int records1stBlock = usingNative ? 5674 : 4480;
private int records2ndBlock = usingNative ? 5574 : 4263;
public void init(String compression, String comparator, String outputFile, public void init(String compression, String comparator, String outputFile,
int numRecords1stBlock, int numRecords2ndBlock) { int numRecords1stBlock, int numRecords2ndBlock) {
@ -89,7 +91,6 @@ public class TestTFileByteArrays {
@Before @Before
public void setUp() throws IOException { public void setUp() throws IOException {
conf = new Configuration();
path = new Path(ROOT, outputFile); path = new Path(ROOT, outputFile);
fs = path.getFileSystem(conf); fs = path.getFileSystem(conf);
out = fs.create(path); out = fs.create(path);