You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2020/01/26 18:45:46 UTC

[hbase] 01/02: HBASE-23737 [Flakey Tests] TestFavoredNodeTableImport fails 30% of the time

This is an automated email from the ASF dual-hosted git repository.

stack pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 887966a6ce3558f3cf5f5c899eb34df686caf1a7
Author: stack <st...@apache.org>
AuthorDate: Fri Jan 24 17:56:42 2020 -0800

    HBASE-23737 [Flakey Tests] TestFavoredNodeTableImport fails 30% of the time
---
 .../balancer/TestFavoredNodeTableImport.java       | 27 +++++++++++++++-------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.java
index 6958ed2..29f0708 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeTableImport.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
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.master.balancer;
 import static org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper.FAVORED_NODES_NUM;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 import java.util.Set;
@@ -34,11 +35,13 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.favored.FavoredNodesManager;
+import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Threads;
 import org.junit.After;
 import org.junit.ClassRule;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
@@ -66,7 +69,6 @@ public class TestFavoredNodeTableImport {
 
   @After
   public void stopCluster() throws Exception {
-    UTIL.cleanupTestDir();
     UTIL.shutdownMiniCluster();
   }
 
@@ -81,13 +83,14 @@ public class TestFavoredNodeTableImport {
       Threads.sleep(1);
     }
     Admin admin = UTIL.getAdmin();
-    admin.setBalancerRunning(false, true);
+    admin.balancerSwitch(false, true);
 
     String tableName = "testFNImport";
     HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
     desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
     admin.createTable(desc, Bytes.toBytes("a"), Bytes.toBytes("z"), REGION_NUM);
     UTIL.waitTableAvailable(desc.getTableName());
+    admin.balancerSwitch(true, true);
 
     LOG.info("Shutting down cluster");
     UTIL.shutdownMiniHBaseCluster();
@@ -97,18 +100,26 @@ public class TestFavoredNodeTableImport {
     UTIL.getConfiguration().set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
         FavoredStochasticBalancer.class.getName());
     UTIL.restartHBaseCluster(SLAVES);
-    while (!UTIL.getMiniHBaseCluster().getMaster().isInitialized()) {
+    HMaster master = UTIL.getMiniHBaseCluster().getMaster();
+    while (!master.isInitialized()) {
       Threads.sleep(1);
     }
-    admin = UTIL.getAdmin();
-
     UTIL.waitTableAvailable(desc.getTableName());
+    UTIL.waitUntilNoRegionsInTransition(10000);
+    assertTrue(master.isBalancerOn());
 
-    FavoredNodesManager fnm = UTIL.getHBaseCluster().getMaster().getFavoredNodesManager();
+    FavoredNodesManager fnm = master.getFavoredNodesManager();
+    assertNotNull(fnm);
 
+    admin = UTIL.getAdmin();
     List<HRegionInfo> regionsOfTable = admin.getTableRegions(TableName.valueOf(tableName));
     for (HRegionInfo rInfo : regionsOfTable) {
-      Set<ServerName> favNodes = Sets.newHashSet(fnm.getFavoredNodes(rInfo));
+      assertNotNull(rInfo);
+      assertNotNull(fnm);
+      List<ServerName> fns = fnm.getFavoredNodes(rInfo);
+      LOG.info("FNS {} {}", rInfo, fns);
+      assertNotNull(rInfo.toString(), fns);
+      Set<ServerName> favNodes = Sets.newHashSet(fns);
       assertNotNull(favNodes);
       assertEquals("Required no of favored nodes not found.", FAVORED_NODES_NUM, favNodes.size());
       for (ServerName fn : favNodes) {