Author: liyin Date: Thu Apr 24 18:18:25 2014 New Revision: 1589816 URL: http://svn.apache.org/r1589816 Log: [HBASE-10986] Fix more hanging tests
Author: elliott Summary: New hanging tests from the last few test runs. One was caused by an integer overflow. I also made TestHRegionClose much faster by changing to a BeforeClass setup. Test Plan: ran each of the tests Reviewers: liyintang, adela Reviewed By: adela CC: hbase-eng@ Differential Revision: https://phabricator.fb.com/D1292046 Task ID: 4142789 Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionStateOnMasterFailure.java hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionClose.java hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionStateOnMasterFailure.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionStateOnMasterFailure.java?rev=1589816&r1=1589815&r2=1589816&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionStateOnMasterFailure.java (original) +++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestRegionStateOnMasterFailure.java Thu Apr 24 18:18:25 2014 @@ -82,7 +82,7 @@ public class TestRegionStateOnMasterFail private static final int NUM_MASTERS = 2; private static final int NUM_RS = 3; - private static final int TEST_TIMEOUT_MS = 90 * 1000 * 1234567; + private static final long TEST_TIMEOUT_MS = 360 * 1000; private static final Pattern META_AND_ROOT_RE = Pattern.compile( (Bytes.toStringBinary(HConstants.META_TABLE_NAME) + "|" + Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionClose.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionClose.java?rev=1589816&r1=1589815&r2=1589816&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionClose.java (original) +++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionClose.java Thu Apr 24 18:18:25 2014 @@ -35,39 +35,50 @@ import org.apache.hadoop.hbase.util.Writ import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper; import org.apache.zookeeper.data.Stat; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; public class TestHRegionClose { private static final Log LOG = LogFactory.getLog(TestHRegionClose.class); - protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - protected static byte[][] FAMILIES = { Bytes.toBytes("f1"), + private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + private static final byte[][] FAMILIES = { Bytes.toBytes("f1"), Bytes.toBytes("f2"), Bytes.toBytes("f3"), Bytes.toBytes("f4") }; - protected HRegionServer server; - protected ZooKeeperWrapper zkWrapper; - protected HRegionInfo regionInfo; - protected String regionZNode; + private static final String TABLE_NAME = TestHRegionClose.class.getName(); + private static int nextRegionIdx = 0; - @Before - public void setUp() throws Exception { - TEST_UTIL.startMiniCluster(3); + private HRegionServer server; + private ZooKeeperWrapper zkWrapper; + private HRegionInfo regionInfo; + private String regionZNode; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + TEST_UTIL.startMiniCluster(1); // Build some data. - byte[] tableName = Bytes.toBytes(getClass().getSimpleName()); + byte[] tableName = Bytes.toBytes(TABLE_NAME); TEST_UTIL.createTable(tableName, FAMILIES, 1, Bytes.toBytes("bbb"), Bytes.toBytes("yyy"), 25); HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName); - for (int i = 0; i < FAMILIES.length; i++) { - byte[] columnFamily = FAMILIES[i]; + for (byte[] columnFamily : FAMILIES) { TEST_UTIL.loadTable(table, columnFamily); } + } + @Before + public void setUp() throws Exception { // Pick a regionserver. server = TEST_UTIL.getHBaseCluster().getRegionServer(0); HRegion[] region = server.getOnlineRegionsAsArray(); - regionInfo = region[0].getRegionInfo(); + regionInfo = null; + + // We need to make sure that we don't get meta or root + while (regionInfo == null || !regionInfo.getTableDesc().getNameAsString().equals(TABLE_NAME)) { + regionInfo = region[nextRegionIdx++].getRegionInfo(); + } // Some initialization relevant to zk. zkWrapper = server.getZooKeeperWrapper(); @@ -75,13 +86,17 @@ public class TestHRegionClose { zkWrapper.getRegionInTransitionZNode(), regionInfo.getEncodedName()); } + @AfterClass + public static void tearDownAfterClass() throws Exception { + TEST_UTIL.shutdownMiniCluster(); + } + @After public void tearDown() throws Exception { server = null; zkWrapper = null; regionInfo = null; regionZNode = null; - TEST_UTIL.shutdownMiniCluster(); } protected void tryCloseRegion() throws Exception { @@ -96,12 +111,12 @@ public class TestHRegionClose { assertEquals(HBaseEventType.RS2ZK_REGION_CLOSED, rsData.getHbEvent()); } - @Test + @Test(timeout = 180000) public void singleClose() throws Exception { tryCloseRegion(); } - @Test + @Test(timeout = 180000) public void doubleClose() throws Exception { tryCloseRegion(); LOG.info("Trying to close the region again, to check that the RegionServer " @@ -109,7 +124,7 @@ public class TestHRegionClose { tryCloseRegion(); } - @Test + @Test(timeout = 180000) public void testMemstoreCleanup() throws Exception { HRegion region = server.getOnlineRegionsAsArray()[0]; Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java?rev=1589816&r1=1589815&r2=1589816&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java (original) +++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java Thu Apr 24 18:18:25 2014 @@ -97,33 +97,13 @@ public class TestThriftServer { } /** - * Runs all of the tests under a single JUnit test method. We - * consolidate all testing to one method because HBaseClusterTestCase - * is prone to OutOfMemoryExceptions when there are three or more - * JUnit test methods. - * - * @throws Exception - */ - public void testAll() throws Exception { - // Run all tests - doTestTableCreateDrop(); - doTestThriftMetrics(); - doTestTableMutations(); - doTestTableTimestampsAndColumns(); - doTestTableScanners(); - doTestGetTableRegions(); - doTestFilterRegistration(); - doTestGetRegionInfo(); - } - - /** * Tests for creating, enabling, disabling, and deleting tables. Also * tests that creating a table with an invalid column name yields an * IllegalArgument exception. * * @throws Exception */ - @Test + @Test(timeout = 180000) public void doTestTableCreateDrop() throws Exception { ThriftServerRunner.HBaseHandler handler = new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration()); @@ -153,7 +133,7 @@ public class TestThriftServer { /** * Tests if the metrics for thrift handler work correctly */ - @Test + @Test(timeout = 180000) public void doTestThriftMetrics() throws Exception { Configuration conf = UTIL.getConfiguration(); ThriftMetrics metrics = getMetrics(conf); @@ -249,7 +229,7 @@ public class TestThriftServer { * * @throws Exception */ - @Test + @Test(timeout = 180000) public void doTestTableMutations() throws Exception { ThriftServerRunner.HBaseHandler handler = new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration()); @@ -368,7 +348,7 @@ public class TestThriftServer { * @throws Exception */ @SuppressWarnings("deprecation") - @Test + @Test(timeout = 180000) public void doTestTableTimestampsAndColumns() throws Exception { // Setup ThriftServerRunner.HBaseHandler handler = @@ -452,7 +432,7 @@ public class TestThriftServer { * * @throws Exception */ - @Test + @Test(timeout = 180000) public void doTestTableScanners() throws Exception { // Setup ThriftServerRunner.HBaseHandler handler = @@ -536,7 +516,7 @@ public class TestThriftServer { * * @throws Exception */ - @Test + @Test(timeout = 180000) public void doTestGetTableRegions() throws Exception { ThriftServerRunner.HBaseHandler handler = new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration()); @@ -564,7 +544,7 @@ public class TestThriftServer { "but found " + regionCount, regionCount, 0); } - @Test + @Test(timeout = 180000) public void doTestFilterRegistration() throws Exception { Configuration conf = UTIL.getConfiguration(); @@ -577,7 +557,7 @@ public class TestThriftServer { assertEquals("filterclass", registeredFilters.get("MyFilter")); } - @Test + @Test(timeout = 180000) public void doTestGetRegionInfo() throws Exception { ThriftServerRunner.HBaseHandler handler = new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
