You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2020/08/11 03:59:28 UTC

[hbase] 02/02: HBASE-23866 More test classifications

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

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

commit 0e3622852599e8d6816d402d6e1052b6945b226b
Author: stack <st...@apache.org>
AuthorDate: Tue Feb 18 21:03:15 2020 -0800

    HBASE-23866 More test classifications
    
    hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java
     Add wait on no region in transition in setup before proceeding.
    
    hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncResultScannerCursor.java
     Make test large. Takes longer than 50seconds.
    
    hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRSCrashPublish.java
     Make large because it fails when networking is weird... when VPN or
     something is up. See HBASE-23850. When large, doesn't get run
     when you do mvn test.
    
    hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java
    hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide2.java
    hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
    hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancerRegionReplica.java
     Make it large. Takes too long.
    
    hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java
     Use data dir instead of /tmp.
    
    M hbase-server/src/test/java/org/apache/hadoop/hbase/http/TestInfoServersACL.java
     Wait till mbean is up before proceeding w/ test.
    
    hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java
     Test for null CLUSTER in tearDown.
---
 .../hbase/client/TestAsyncMetaRegionLocator.java   |  5 +-
 .../hbase/client/TestAsyncResultScannerCursor.java |  6 +-
 .../hbase/client/TestAsyncTableRSCrashPublish.java | 68 ++++++++++++++--------
 .../hadoop/hbase/client/TestAsyncTableScanAll.java |  6 +-
 .../hbase/client/TestScannersFromClientSide2.java  |  6 +-
 .../hbase/client/TestSeparateClientZKCluster.java  |  5 +-
 .../hbase/filter/TestMultiRowRangeFilter.java      |  6 +-
 .../hadoop/hbase/http/TestInfoServersACL.java      | 20 +++++++
 .../TestStochasticLoadBalancerRegionReplica.java   |  6 +-
 .../hbase/security/token/SecureTestCluster.java    |  2 +-
 10 files changed, 84 insertions(+), 46 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java
index 1f0d40b..a228043 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncMetaRegionLocator.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
@@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.RegionLocations;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.RegionReplicaTestHelper.Locator;
-import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.junit.AfterClass;
@@ -51,9 +50,9 @@ public class TestAsyncMetaRegionLocator {
 
   @BeforeClass
   public static void setUp() throws Exception {
-    TEST_UTIL.getConfiguration().set(BaseLoadBalancer.TABLES_ON_MASTER, "none");
     TEST_UTIL.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 3);
     TEST_UTIL.startMiniCluster(3);
+    TEST_UTIL.waitUntilNoRegionsInTransition();
     REGISTRY = AsyncRegistryFactory.getRegistry(TEST_UTIL.getConfiguration());
     RegionReplicaTestHelper
       .waitUntilAllMetaReplicasHavingRegionLocation(TEST_UTIL.getConfiguration(), REGISTRY, 3);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncResultScannerCursor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncResultScannerCursor.java
index 638ae8c..d8e293c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncResultScannerCursor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncResultScannerCursor.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,12 +20,12 @@ package org.apache.hadoop.hbase.client;
 import java.util.concurrent.ForkJoinPool;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 
-@Category({ MediumTests.class, ClientTests.class })
+@Category({ LargeTests.class, ClientTests.class })
 public class TestAsyncResultScannerCursor extends AbstractTestResultScannerCursor {
 
   @ClassRule
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRSCrashPublish.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRSCrashPublish.java
index 849feb8..461bf1b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRSCrashPublish.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRSCrashPublish.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
@@ -18,15 +18,16 @@
 package org.apache.hadoop.hbase.client;
 
 import static org.junit.Assert.assertNotEquals;
-
 import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -34,9 +35,10 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
-
-@Category({ MediumTests.class, ClientTests.class })
+// Categorized as a large test so not run as part of general 'test' suite (which is small
+// and mediums). This test fails if networking is odd -- say if you are connected to a
+// VPN... See HBASE-23850
+@Category({ LargeTests.class, ClientTests.class })
 public class TestAsyncTableRSCrashPublish {
 
   @ClassRule
@@ -45,40 +47,56 @@ public class TestAsyncTableRSCrashPublish {
 
   private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
 
-  private static AsyncConnectionImpl CONN;
-
   private static TableName TABLE_NAME = TableName.valueOf("Publish");
 
   private static byte[] FAMILY = Bytes.toBytes("family");
 
   @BeforeClass
-  public static void setUp() throws Exception {
+  public static void beforeClass() throws Exception {
     UTIL.getConfiguration().setBoolean(HConstants.STATUS_PUBLISHED, true);
+    /* Below is code for choosing a NetworkInterface and then setting it into
+      configs so can be picked up by the client and server.
+    String niName = UTIL.getConfiguration().get(HConstants.STATUS_MULTICAST_NI_NAME);
+    NetworkInterface ni;
+    if (niName != null) {
+      ni = NetworkInterface.getByName(niName);
+    } else {
+      String mcAddress = UTIL.getConfiguration().get(HConstants.STATUS_MULTICAST_ADDRESS,
+        HConstants.DEFAULT_STATUS_MULTICAST_ADDRESS);
+      InetAddress ina = InetAddress.getByName(mcAddress);
+      boolean inet6Address = ina instanceof Inet6Address;
+      ni = NetworkInterface.getByInetAddress(inet6Address?
+        Addressing.getIp6Address(): Addressing.getIp4Address());
+    }
+    UTIL.getConfiguration().set(HConstants.STATUS_MULTICAST_NI_NAME, ni.getName());
+    */
     UTIL.startMiniCluster(2);
     UTIL.createTable(TABLE_NAME, FAMILY);
     UTIL.waitTableAvailable(TABLE_NAME);
-    CONN =
-      (AsyncConnectionImpl) ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get();
   }
 
   @AfterClass
-  public static void tearDown() throws Exception {
-    Closeables.close(CONN, true);
+  public static void afterClass() throws Exception {
     UTIL.shutdownMiniCluster();
   }
 
   @Test
-  public void test() throws IOException {
-    AsyncNonMetaRegionLocator locator = CONN.getLocator().getNonMetaRegionLocator();
-    CONN.getTable(TABLE_NAME).get(new Get(Bytes.toBytes(0))).join();
-    ServerName serverName = locator.getRegionLocationInCache(TABLE_NAME, HConstants.EMPTY_START_ROW)
-      .getDefaultRegionLocation().getServerName();
-    UTIL.getMiniHBaseCluster().stopRegionServer(serverName);
-    UTIL.waitFor(60000,
-      () -> locator.getRegionLocationInCache(TABLE_NAME, HConstants.EMPTY_START_ROW) == null);
-    CONN.getTable(TABLE_NAME).get(new Get(Bytes.toBytes(0))).join();
-    assertNotEquals(serverName,
-      locator.getRegionLocationInCache(TABLE_NAME, HConstants.EMPTY_START_ROW)
-        .getDefaultRegionLocation().getServerName());
+  public void test() throws IOException, ExecutionException, InterruptedException {
+    Configuration conf = UTIL.getHBaseCluster().getMaster().getConfiguration();
+    try (AsyncConnection connection = ConnectionFactory.createAsyncConnection(conf).get()) {
+      AsyncNonMetaRegionLocator locator =
+        ((AsyncConnectionImpl) connection).getLocator().getNonMetaRegionLocator();
+      connection.getTable(TABLE_NAME).get(new Get(Bytes.toBytes(0))).join();
+      ServerName serverName =
+        locator.getRegionLocationInCache(TABLE_NAME, HConstants.EMPTY_START_ROW)
+        .getDefaultRegionLocation().getServerName();
+      UTIL.getMiniHBaseCluster().stopRegionServer(serverName);
+      UTIL.waitFor(60000,
+        () -> locator.getRegionLocationInCache(TABLE_NAME, HConstants.EMPTY_START_ROW) == null);
+      connection.getTable(TABLE_NAME).get(new Get(Bytes.toBytes(0))).join();
+      assertNotEquals(serverName,
+        locator.getRegionLocationInCache(TABLE_NAME, HConstants.EMPTY_START_ROW)
+          .getDefaultRegionLocation().getServerName());
+    }
   }
 }
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java
index b8adbce..d9a5395 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.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
@@ -21,7 +21,7 @@ import java.util.List;
 import java.util.function.Supplier;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
@@ -30,7 +30,7 @@ import org.junit.runners.Parameterized.Parameter;
 import org.junit.runners.Parameterized.Parameters;
 
 @RunWith(Parameterized.class)
-@Category({ MediumTests.class, ClientTests.class })
+@Category({ LargeTests.class, ClientTests.class })
 public class TestAsyncTableScanAll extends AbstractTestAsyncTableScan {
 
   @ClassRule
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide2.java
index 0a10818..d973051 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide2.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
@@ -28,7 +28,7 @@ import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -45,7 +45,7 @@ import org.junit.runners.Parameterized.Parameters;
  * inclusive/exclusive, limit for rows, etc.
  */
 @RunWith(Parameterized.class)
-@Category({ MediumTests.class, ClientTests.class })
+@Category({ LargeTests.class, ClientTests.class })
 public class TestScannersFromClientSide2 {
 
   @ClassRule
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java
index f44ef28..816801c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.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
@@ -48,7 +48,8 @@ import org.slf4j.LoggerFactory;
 public class TestSeparateClientZKCluster {
   private static final Logger LOG = LoggerFactory.getLogger(TestSeparateClientZKCluster.class);
   private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
-  private static final File clientZkDir = new File("/tmp/TestSeparateClientZKCluster");
+  private static final File clientZkDir =
+    new File(TEST_UTIL.getDataTestDir("TestSeparateClientZKCluster").toString());
   private static final int ZK_SESSION_TIMEOUT = 5000;
   private static MiniZooKeeperCluster clientZkCluster;
 
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
index 00c557c..9f8cca2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.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
@@ -35,7 +35,7 @@ import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.AfterClass;
 import org.junit.Assert;
@@ -48,7 +48,7 @@ import org.junit.rules.TestName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@Category(MediumTests.class)
+@Category(LargeTests.class)
 public class TestMultiRowRangeFilter {
 
   @ClassRule
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/http/TestInfoServersACL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/http/TestInfoServersACL.java
index fa5dea6..69b0a2d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/http/TestInfoServersACL.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/http/TestInfoServersACL.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.lang.management.ManagementFactory;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.security.PrivilegedExceptionAction;
@@ -34,6 +35,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.LocalHBaseCluster;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
 import org.apache.hadoop.hbase.security.token.TokenProvider;
@@ -41,6 +43,7 @@ import org.apache.hadoop.hbase.testclassification.MiscTests;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.minikdc.MiniKdc;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.http.auth.AuthSchemeProvider;
@@ -70,6 +73,10 @@ import org.junit.rules.TestName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanInfo;
+import javax.management.ObjectName;
+
 /**
  * Testing info servers for admin acl.
  */
@@ -300,6 +307,19 @@ public class TestInfoServersACL {
   @Test
   public void testJmxAvailableForAdmins() throws Exception {
     final String expectedAuthorizedContent = "Hadoop:service=HBase";
+    UTIL.waitFor(30000, new Waiter.Predicate<Exception>() {
+      @Override
+      public boolean evaluate() throws Exception {
+        for (ObjectName name: ManagementFactory.getPlatformMBeanServer().
+          queryNames(new ObjectName("*:*"), null)) {
+          if (name.toString().contains(expectedAuthorizedContent)) {
+            LOG.info("{}", name);
+            return true;
+          }
+        }
+        return false;
+      }
+    });
     UserGroupInformation admin = UserGroupInformation.loginUserFromKeytabAndReturnUGI(
         USER_ADMIN_STR, KEYTAB_FILE.getAbsolutePath());
     admin.doAs(new PrivilegedExceptionAction<Void>() {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancerRegionReplica.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancerRegionReplica.java
index f5a8cba..9634f9a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancerRegionReplica.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancerRegionReplica.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
@@ -36,13 +36,13 @@ import org.apache.hadoop.hbase.client.RegionInfo;
 import org.apache.hadoop.hbase.client.RegionReplicaUtil;
 import org.apache.hadoop.hbase.master.RackManager;
 import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-@Category({ MasterTests.class, MediumTests.class })
+@Category({ MasterTests.class, LargeTests.class })
 public class TestStochasticLoadBalancerRegionReplica extends BalancerTestBase {
 
   @ClassRule
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java
index 1323946..5b6dadc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java
@@ -98,8 +98,8 @@ public class SecureTestCluster {
     try {
       if (CLUSTER != null) {
         CLUSTER.shutdown();
+        CLUSTER.join();
       }
-      CLUSTER.join();
       if (KDC != null) {
         KDC.stop();
       }