From d190372bfca4250206ce4c79d8dac26ad3d6e07d Mon Sep 17 00:00:00 2001 From: jxiang Date: Fri, 9 Aug 2013 04:13:34 +0000 Subject: [PATCH] HBASE-9161 TestAssignmentManagerOnCluster.testSSHWhenDisablingTableRegionsInOpeningOrPendingOpenState could hang git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1512134 13f79535-47bb-0310-9956-ffa450edef68 --- .../TestAssignmentManagerOnCluster.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java index 07d3dad48f3..371f969a4c5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java @@ -31,7 +31,6 @@ import java.util.Set; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; @@ -40,6 +39,7 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MediumTests; import org.apache.hadoop.hbase.ServerLoad; import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.catalog.MetaEditor; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.client.HTable; @@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.zookeeper.ZKAssign; +import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -483,10 +484,18 @@ public class TestAssignmentManagerOnCluster { } } am.regionOffline(hri); - ZKAssign.createNodeOffline(TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper(), hri, - destServerName); - ZKAssign.transitionNodeOpening(TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper(), hri, - destServerName); + ZooKeeperWatcher zkw = TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper(); + ZKAssign.createNodeOffline(zkw, hri, destServerName); + ZKAssign.transitionNodeOpening(zkw, hri, destServerName); + + // Wait till the event is processed and the region is in transition + long timeoutTime = System.currentTimeMillis() + 20000; + while (!am.getRegionStates().isRegionInTransition(hri)) { + assertTrue("Failed to process ZK opening event in time", + System.currentTimeMillis() < timeoutTime); + Thread.sleep(100); + } + am.getZKTable().setDisablingTable(table); List toAssignRegions = am.processServerShutdown(destServerName); assertTrue("Regions to be assigned should be empty.", toAssignRegions.isEmpty());