From c5690b1be3ae84efa52ee3c4589248c447e12f3f Mon Sep 17 00:00:00 2001 From: stack Date: Thu, 20 Nov 2014 17:54:39 -0800 Subject: [PATCH] HBASE-12541 Add misc debug logging to hanging tests in TestHCM and TestBaseLoadBalancer --- .../org/apache/hadoop/hbase/client/TestHCM.java | 12 ++++++++---- .../hadoop/hbase/client/TestMultiParallel.java | 2 +- .../master/balancer/TestBaseLoadBalancer.java | 16 ++++++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index 3e29725ec0d..5a6065c2ec8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -1007,7 +1007,7 @@ public class TestHCM { return prevNumRetriesVal; } - @Test + @Test (timeout=30000) public void testMulti() throws Exception { HTable table = TEST_UTIL.createTable(TABLE_NAME3, FAM_NAM); TEST_UTIL.createMultiRegions(table, FAM_NAM); @@ -1024,9 +1024,7 @@ public class TestHCM { HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); // We can wait for all regions to be online, that makes log reading easier when debugging - while (master.getAssignmentManager().getRegionStates().isRegionsInTransition()) { - Thread.sleep(1); - } + TEST_UTIL.waitUntilNoRegionsInTransition(20000); Put put = new Put(ROW_X); put.add(FAM_NAM, ROW_X, ROW_X); @@ -1034,6 +1032,12 @@ public class TestHCM { // Now moving the region to the second server HRegionLocation toMove = conn.getCachedLocation(TABLE_NAME3, ROW_X).getRegionLocation(); + if (toMove == null) { + String msg = "Failed to find location for " + Bytes.toString(ROW_X) + " in " + TABLE_NAME3; + // Log so easier to see in output where error occurred. + LOG.error(msg); + throw new NullPointerException(msg); + } byte[] regionName = toMove.getRegionInfo().getRegionName(); byte[] encodedRegionNameBytes = toMove.getRegionInfo().getEncodedNameAsBytes(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java index 20828ecdd23..388b3c9241e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java @@ -331,7 +331,6 @@ public class TestMultiParallel { public void testBatchWithPut() throws Exception { LOG.info("test=testBatchWithPut"); Table table = new HTable(UTIL.getConfiguration(), TEST_TABLE); - // put multiple rows using a batch List puts = constructPutRequests(); @@ -677,6 +676,7 @@ public class TestMultiParallel { private void validateLoadedData(Table table) throws IOException { // get the data back and validate that it is correct + LOG.info("Validating data on " + table); for (byte[] k : KEYS) { Get get = new Get(k); get.addColumn(BYTES_FAMILY, QUALIFIER); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java index acd7d06e7e0..11ca6c712d0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBaseLoadBalancer.java @@ -115,7 +115,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase { * * @throws Exception */ - @Test + @Test (timeout=30000) public void testImmediateAssignment() throws Exception { List tmp = getListOfServerNames(randomServers(1, 0)); tmp.add(master); @@ -161,7 +161,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase { * * @throws Exception */ - @Test + @Test (timeout=180000) public void testBulkAssignment() throws Exception { List tmp = getListOfServerNames(randomServers(5, 0)); List hris = randomRegions(20); @@ -200,7 +200,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase { * assignment info. * @throws Exception */ - @Test + @Test (timeout=180000) public void testRetainAssignment() throws Exception { // Test simple case where all same servers are there List servers = randomServers(10, 10); @@ -236,7 +236,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase { assertRetainedAssignment(existing, listOfServerNames, assignment); } - @Test + @Test (timeout=180000) public void testRegionAvailability() throws Exception { // Create a cluster with a few servers, assign them to specific racks // then assign some regions. The tests should check whether moving a @@ -310,7 +310,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase { assertTrue(!cluster.wouldLowerAvailability(hri1, servers[6])); } - @Test + @Test (timeout=180000) public void testRegionAvailabilityWithRegionMoves() throws Exception { List list0 = new ArrayList(); List list1 = new ArrayList(); @@ -422,7 +422,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase { } } - @Test + @Test (timeout=180000) public void testClusterServersWithSameHostPort() { // tests whether the BaseLoadBalancer.Cluster can be constructed with servers // sharing same host and port @@ -462,7 +462,7 @@ public class TestBaseLoadBalancer extends BalancerTestBase { } } - @Test + @Test (timeout=180000) public void testClusterRegionLocations() { // tests whether region locations are handled correctly in Cluster List servers = getListOfServerNames(randomServers(10, 10)); @@ -521,4 +521,4 @@ public class TestBaseLoadBalancer extends BalancerTestBase { assertEquals(1, cluster.regionLocations[r43].length); assertEquals(-1, cluster.regionLocations[r43][0]); } -} +} \ No newline at end of file