Repository: hbase Updated Branches: refs/heads/branch-1 ef3b59cb7 -> 96b86b71d refs/heads/branch-1.3 d4acc9b68 -> 26ff42091 refs/heads/branch-1.4 fc00fcc3c -> 4a3183dc9 refs/heads/branch-2 57aa6b32a -> d0fb4bd78 refs/heads/master 80741e31e -> 9ed6cf5cb
HBASE-19250 TestClientClusterStatus is flaky Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/45116c8a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/45116c8a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/45116c8a Branch: refs/heads/branch-1 Commit: 45116c8a52d7114d87924478ae4381c4f88e90fd Parents: ef3b59c Author: Andrew Purtell <apurt...@apache.org> Authored: Mon Nov 13 16:50:24 2017 -0800 Committer: Andrew Purtell <apurt...@apache.org> Committed: Mon Nov 13 16:52:36 2017 -0800 ---------------------------------------------------------------------- .../hadoop/hbase/client/TestClientClusterStatus.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/45116c8a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java index 197b0d9..474e6a7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientClusterStatus.java @@ -26,6 +26,8 @@ import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.Waiter; +import org.apache.hadoop.hbase.Waiter.Predicate; import org.apache.hadoop.hbase.coprocessor.BaseMasterObserver; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; @@ -86,9 +88,9 @@ public class TestClientClusterStatus { Assert.assertTrue(origin.equals(defaults)); } - @Test public void testLiveAndDeadServersStatus() throws Exception { + // Count the number of live regionservers List<RegionServerThread> regionserverThreads = CLUSTER.getLiveRegionServerThreads(); int numRs = 0; int len = regionserverThreads.size(); @@ -98,6 +100,16 @@ public class TestClientClusterStatus { } } // Retrieve live servers and dead servers info. + // Depending on the (random) order of unit execution we may run this unit before the + // minicluster is fully up and recovered from the RS shutdown done during test init. + Waiter.waitFor(CLUSTER.getConfiguration(), 10 * 1000, 100, new Predicate<Exception>() { + @Override + public boolean evaluate() throws Exception { + ClusterStatus status = ADMIN.getClusterStatus(); + Assert.assertNotNull(status); + return status.getRegionsCount() > 0; + } + }); ClusterStatus status = ADMIN.getClusterStatus(); Assert.assertNotNull(status); Assert.assertNotNull(status.getServers());