HADOOP-1391. Split test case for merge into two so it does not time out in Hudson

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@543862 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Kellerman 2007-06-03 08:52:06 +00:00
parent 66839c4c17
commit 7c3d11974b
3 changed files with 83 additions and 42 deletions

View File

@ -25,44 +25,19 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Text;
/** Tests region merging */ /** Abstract base class for merge tests */
public class TestMerge extends HBaseTestCase { public abstract class AbstractMergeTestBase extends HBaseTestCase {
private static final Text COLUMN_NAME = new Text("contents:"); protected static final Text COLUMN_NAME = new Text("contents:");
private Random rand; protected Random rand;
private HTableDescriptor desc; protected HTableDescriptor desc;
private BytesWritable value; protected BytesWritable value;
private MiniDFSCluster dfsCluster; protected MiniDFSCluster dfsCluster;
private FileSystem fs; protected FileSystem fs;
private Path dir; protected Path dir;
private MiniHBaseCluster hCluster; public void setUp() throws Exception {
super.setUp();
public void testMerge() {
setup();
startMiniDFSCluster();
createRegions();
try {
HMerge.merge(conf, fs, HConstants.META_TABLE_NAME);
hCluster = new MiniHBaseCluster(conf, 1, dfsCluster);
try {
HMerge.merge(conf, fs, desc.getName());
} finally {
hCluster.shutdown();
}
} catch(Throwable t) {
t.printStackTrace();
fail();
} finally {
dfsCluster.shutdown();
}
}
private void setup() {
rand = new Random(); rand = new Random();
desc = new HTableDescriptor("test"); desc = new HTableDescriptor("test");
desc.addFamily(new HColumnDescriptor(COLUMN_NAME.toString())); desc.addFamily(new HColumnDescriptor(COLUMN_NAME.toString()));
@ -80,9 +55,7 @@ public class TestMerge extends HBaseTestCase {
} catch(UnsupportedEncodingException e) { } catch(UnsupportedEncodingException e) {
fail(); fail();
} }
}
private void startMiniDFSCluster() {
try { try {
dfsCluster = new MiniDFSCluster(conf, 2, true, (String[])null); dfsCluster = new MiniDFSCluster(conf, 2, true, (String[])null);
fs = dfsCluster.getFileSystem(); fs = dfsCluster.getFileSystem();
@ -93,9 +66,7 @@ public class TestMerge extends HBaseTestCase {
t.printStackTrace(); t.printStackTrace();
fail(); fail();
} }
}
private void createRegions() {
// We create three data regions: The first is too large to merge since it // We create three data regions: The first is too large to merge since it
// will be > 64 MB in size. The second two will be smaller and will be // will be > 64 MB in size. The second two will be smaller and will be
// selected for merging. // selected for merging.
@ -139,7 +110,12 @@ public class TestMerge extends HBaseTestCase {
fail(); fail();
} }
} }
public void tearDown() throws Exception {
super.tearDown();
dfsCluster.shutdown();
}
private HRegion createAregion(Text startKey, Text endKey, int firstRow, int nrows) private HRegion createAregion(Text startKey, Text endKey, int firstRow, int nrows)
throws IOException { throws IOException {
HRegion region = HRegion.createNewHRegion(fs, dir, conf, desc, HRegion region = HRegion.createNewHRegion(fs, dir, conf, desc,

View File

@ -0,0 +1,30 @@
/**
* Copyright 2007 The Apache Software Foundation
*
* Licensed 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.hadoop.hbase;
/** Tests region merging */
public class TestMergeMeta extends AbstractMergeTestBase {
public void testMergeMeta() {
try {
HMerge.merge(conf, fs, HConstants.META_TABLE_NAME);
} catch(Throwable t) {
t.printStackTrace();
fail();
}
}
}

View File

@ -0,0 +1,35 @@
/**
* Copyright 2007 The Apache Software Foundation
*
* Licensed 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.hadoop.hbase;
public class TestMergeTable extends AbstractMergeTestBase {
public void testMergeTable() {
try {
MiniHBaseCluster hCluster = new MiniHBaseCluster(conf, 1, dfsCluster);
try {
HMerge.merge(conf, fs, desc.getName());
} finally {
hCluster.shutdown();
}
} catch(Throwable t) {
t.printStackTrace();
fail();
}
}
}