hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [02/50] [abbrv] hbase git commit: HBASE-13406 TestAccessController is flaky when create is slow
Date Thu, 09 Apr 2015 20:59:07 GMT
HBASE-13406 TestAccessController is flaky when create is slow


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/fef8ae9c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/fef8ae9c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/fef8ae9c

Branch: refs/heads/hbase-12439
Commit: fef8ae9c70f47d87baa985a66e94d7b90b861f08
Parents: e252c30
Author: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Authored: Sat Apr 4 00:03:07 2015 +0100
Committer: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Committed: Sat Apr 4 10:17:11 2015 +0100

----------------------------------------------------------------------
 .../hbase/security/access/SecureTestUtil.java   | 28 +++++++++++++++++++-
 .../access/TestAccessControlFilter.java         |  2 +-
 .../security/access/TestAccessController.java   |  5 ++--
 .../security/access/TestAccessController2.java  |  6 ++---
 4 files changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/fef8ae9c/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java
index c45accd..b30c770 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java
@@ -36,6 +36,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Coprocessor;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
@@ -633,19 +634,44 @@ public class SecureTestUtil {
     }
   }
 
+  public static Table createTable(HBaseTestingUtility testUtil, TableName tableName,
+      byte[][] families) throws Exception {
+    HTableDescriptor htd = new HTableDescriptor(tableName);
+    for (byte[] family : families) {
+      HColumnDescriptor hcd = new HColumnDescriptor(family);
+      htd.addFamily(hcd);
+    }
+    createTable(testUtil, testUtil.getHBaseAdmin(), htd);
+    return testUtil.getConnection().getTable(htd.getTableName());
+  }
+
   public static void createTable(HBaseTestingUtility testUtil, HTableDescriptor htd)
       throws Exception {
     createTable(testUtil, testUtil.getHBaseAdmin(), htd);
   }
 
+  public static void createTable(HBaseTestingUtility testUtil, HTableDescriptor htd,
+      byte[][] splitKeys) throws Exception {
+    createTable(testUtil, testUtil.getHBaseAdmin(), htd, splitKeys);
+  }
+
   public static void createTable(HBaseTestingUtility testUtil, Admin admin, HTableDescriptor
htd)
       throws Exception {
+    createTable(testUtil, admin, htd, null);
+  }
+
+  public static void createTable(HBaseTestingUtility testUtil, Admin admin, HTableDescriptor
htd,
+      byte[][] splitKeys) throws Exception {
     // NOTE: We need a latch because admin is not sync,
     // so the postOp coprocessor method may be called after the admin operation returned.
     MasterSyncObserver observer = (MasterSyncObserver)testUtil.getHBaseCluster().getMaster()
       .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName());
     observer.tableCreationLatch = new CountDownLatch(1);
-    admin.createTable(htd);
+    if (splitKeys != null) {
+      admin.createTable(htd, splitKeys);
+    } else {
+      admin.createTable(htd);
+    }
     observer.tableCreationLatch.await();
     observer.tableCreationLatch = null;
     testUtil.waitUntilAllRegionsAssigned(htd.getTableName());

http://git-wip-us.apache.org/repos/asf/hbase/blob/fef8ae9c/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessControlFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessControlFilter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessControlFilter.java
index d6a6f03..5d58110 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessControlFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessControlFilter.java
@@ -94,7 +94,7 @@ public class TestAccessControlFilter extends SecureTestUtil {
 
   @Test
   public void testQualifierAccess() throws Exception {
-    final Table table = TEST_UTIL.createTable(TABLE, FAMILY);
+    final Table table = createTable(TEST_UTIL, TABLE, new byte[][] { FAMILY });
     try {
       doQualifierAccess(table);
     } finally {

http://git-wip-us.apache.org/repos/asf/hbase/blob/fef8ae9c/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
index 1b496a0..58b8587 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
@@ -235,8 +235,7 @@ public class TestAccessController extends SecureTestUtil {
     hcd.setMaxVersions(100);
     htd.addFamily(hcd);
     htd.setOwner(USER_OWNER);
-    admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
-    TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE.getTableName());
+    createTable(TEST_UTIL, htd, new byte[][] { Bytes.toBytes("s") });
 
     Region region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
     RegionCoprocessorHost rcpHost = region.getCoprocessorHost();
@@ -630,8 +629,8 @@ public class TestAccessController extends SecureTestUtil {
 
   @Test
   public void testMergeRegions() throws Exception {
-
     final List<HRegion> regions = TEST_UTIL.getHBaseCluster().findRegionsForTable(TEST_TABLE.getTableName());
+    assertTrue("not enough regions: " + regions.size(), regions.size() >= 2);
 
     AccessTestAction action = new AccessTestAction() {
       @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/fef8ae9c/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
index 31a3cec..24cd1d8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
@@ -120,9 +120,9 @@ public class TestAccessController2 extends SecureTestUtil {
   @Before
   public void setUp() throws Exception {
     createNamespace(TEST_UTIL, NamespaceDescriptor.create(namespace).build());
-    try (Table table = TEST_UTIL.createTable(tableName,
-          new String[] { Bytes.toString(TEST_FAMILY), Bytes.toString(TEST_FAMILY_2) })) {
-      TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
+    try (Table table = createTable(TEST_UTIL, tableName,
+          new byte[][] { TEST_FAMILY, TEST_FAMILY_2 })) {
+      TEST_UTIL.waitTableEnabled(tableName);
 
       // Ingesting test data.
       table.put(Arrays.asList(new Put(TEST_ROW).addColumn(TEST_FAMILY, Q1, value1),


Mime
View raw message