From e6d2682f0f918eecd901b5757e4b3d23a9612c30 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 31 Jan 2018 15:17:38 -0800 Subject: [PATCH] HBASE-19907 TestMetaWithReplicas still flakey --- .../hadoop/hbase/client/TestMetaWithReplicas.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java index 4f38fbedcc5..a87bd7cd7e7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.client; import static org.apache.hadoop.hbase.util.hbck.HbckTestingUtil.assertErrors; import static org.apache.hadoop.hbase.util.hbck.HbckTestingUtil.doFsck; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -113,11 +114,20 @@ public class TestMetaWithReplicas { // Fun. All meta region replicas have ended up on the one server. This will cause this test // to fail ... sometimes. if (sns.size() == 1) { + int count = TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size(); + assertTrue("count=" + count, count == REGIONSERVERS_COUNT); LOG.warn("All hbase:meta replicas are on the one server; moving hbase:meta"); int metaServerIndex = TEST_UTIL.getHBaseCluster().getServerWithMeta(); - int newServerIndex = (metaServerIndex + 1) % REGIONSERVERS_COUNT; + int newServerIndex = metaServerIndex; + while (newServerIndex == metaServerIndex) { + newServerIndex = (newServerIndex + 1) % REGIONSERVERS_COUNT; + } + assertNotEquals(metaServerIndex, newServerIndex); ServerName destinationServerName = TEST_UTIL.getHBaseCluster().getRegionServer(newServerIndex).getServerName(); + ServerName metaServerName = + TEST_UTIL.getHBaseCluster().getRegionServer(metaServerIndex).getServerName(); + assertNotEquals(destinationServerName, metaServerName); TEST_UTIL.getAdmin().move(RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes(), Bytes.toBytes(destinationServerName.toString())); }