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 2015/02/25 02:01:17 UTC

hbase git commit: HBASE-13084 Add labels to VisibilityLabelsCache asynchronously causes TestShell flakey

Repository: hbase
Updated Branches:
  refs/heads/master c3a9c2a87 -> d34620b8b


HBASE-13084 Add labels to VisibilityLabelsCache asynchronously causes TestShell flakey

Signed-off-by: stack <st...@apache.org>


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

Branch: refs/heads/master
Commit: d34620b8b661b17d55dd75d24e56c5a7ee661b4e
Parents: c3a9c2a
Author: zhangduo <zh...@wandoujia.com>
Authored: Tue Feb 24 18:18:35 2015 +0800
Committer: stack <st...@apache.org>
Committed: Tue Feb 24 17:01:05 2015 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/HBaseTestingUtility.java       | 32 ++++++++++++++++++++
 .../ruby/hbase/visibility_labels_admin_test.rb  |  2 ++
 2 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d34620b8/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index c1897cf..0ef7887 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -99,6 +99,7 @@ import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;
 import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL;
 import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;
 import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.security.visibility.VisibilityLabelsCache;
 import org.apache.hadoop.hbase.tool.Canary;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.FSTableDescriptors;
@@ -3852,6 +3853,37 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
   }
 
   /**
+   * Wait until labels is ready in VisibilityLabelsCache.
+   * @param timeoutMillis
+   * @param labels
+   */
+  public void waitLabelAvailable(long timeoutMillis, final String... labels) {
+    final VisibilityLabelsCache labelsCache = VisibilityLabelsCache.get();
+    waitFor(timeoutMillis, new Waiter.ExplainingPredicate<RuntimeException>() {
+
+      @Override
+      public boolean evaluate() {
+        for (String label : labels) {
+          if (labelsCache.getLabelOrdinal(label) == 0) {
+            return false;
+          }
+        }
+        return true;
+      }
+
+      @Override
+      public String explainFailure() {
+        for (String label : labels) {
+          if (labelsCache.getLabelOrdinal(label) == 0) {
+            return label + " is not available yet";
+          }
+        }
+        return "";
+      }
+    });
+  }
+
+  /**
    * Create a set of column descriptors with the combination of compression,
    * encoding, bloom codecs available.
    * @return the list of column descriptors

http://git-wip-us.apache.org/repos/asf/hbase/blob/d34620b8/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb b/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb
index 0815d83..47ac292 100644
--- a/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb
@@ -54,6 +54,7 @@ module Hbase
       label = 'TEST_AUTHS'
       user = org.apache.hadoop.hbase.security.User.getCurrent().getName();
       visibility_admin.add_labels(label)
+      $TEST_CLUSTER.waitLabelAvailable(10000, label)
       count = visibility_admin.get_auths(user).length
 
       # verifying the set functionality
@@ -74,6 +75,7 @@ module Hbase
       label = 'TEST_VISIBILITY'
       user = org.apache.hadoop.hbase.security.User.getCurrent().getName();
       visibility_admin.add_labels(label)
+      $TEST_CLUSTER.waitLabelAvailable(10000, label)
       visibility_admin.set_auths(user, label)
 
       # verifying put functionality