From c19520a9563929e84fd3657758f827d6519bcf64 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Fri, 18 Jan 2013 18:49:42 +0000 Subject: [PATCH] HBASE-7299 TestMultiParallel fails intermittently in trunk builds, addendum 4 (Chunhui) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1435301 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/client/TestMultiParallel.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 00b2b07dd05..e9ac90de06b 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 @@ -18,6 +18,11 @@ */ package org.apache.hadoop.hbase.client; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; @@ -27,9 +32,13 @@ import java.util.concurrent.ThreadPoolExecutor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.impl.Log4JLogger; -import org.apache.hadoop.hbase.*; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.MediumTests; +import org.apache.hadoop.hbase.Waiter.Predicate; import org.apache.hadoop.hbase.ipc.HBaseClient; import org.apache.hadoop.hbase.ipc.HBaseServer; +import org.apache.hadoop.hbase.master.RegionStates; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.JVMClusterUtil; @@ -41,8 +50,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; -import static org.junit.Assert.*; - @Category(MediumTests.class) public class TestMultiParallel { private static final Log LOG = LogFactory.getLog(TestMultiParallel.class); @@ -73,11 +80,20 @@ public class TestMultiParallel { UTIL.shutdownMiniCluster(); } - @Before public void before() throws IOException { + @Before public void before() throws Exception { LOG.info("before"); if (UTIL.ensureSomeRegionServersAvailable(slaves)) { // Distribute regions UTIL.getMiniHBaseCluster().getMaster().balance(); + // Wait until completing balance + final RegionStates regionStates = UTIL.getMiniHBaseCluster().getMaster() + .getAssignmentManager().getRegionStates(); + UTIL.waitFor(15 * 1000, new Predicate() { + @Override + public boolean evaluate() throws Exception { + return !regionStates.isRegionsInTransition(); + } + }); } LOG.info("before done"); }