diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java index e3fc2ac9ee0..ae85552b2ad 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java @@ -1797,14 +1797,20 @@ public void getUserPermissions(RpcController controller, } } - // Copied from org.apache.hadoop.hbase.security.access.SecureTestUtil because it's not visible - // there + // Based on org.apache.hadoop.hbase.security.access.SecureTestUtil, which is not visible here. private static List getAccessControllers(MiniHBaseCluster cluster) { List result = Lists.newArrayList(); + // The master checks grant, revoke and DDL requests against its own permission cache. + // Thus the wait must also include the master. + // The lookup uses the class type. Thus it also finds subclasses of AccessController. + AccessController masterAc = + cluster.getMaster().getMasterCoprocessorHost().findCoprocessor(AccessController.class); + if (masterAc != null) { + result.add(masterAc); + } for (RegionServerThread t : cluster.getLiveRegionServerThreads()) { for (HRegion region : t.getRegionServer().getOnlineRegionsLocalContext()) { - Coprocessor cp = - region.getCoprocessorHost().findCoprocessor(AccessController.class.getName()); + Coprocessor cp = region.getCoprocessorHost().findCoprocessor(AccessController.class); if (cp != null) { result.add((AccessController) cp); } @@ -1813,6 +1819,13 @@ private static List getAccessControllers(MiniHBaseCluster clus return result; } + // Identify the controller in log messages. The master controller has no region. + private static String describe(AccessController ac) { + return ac.getRegion() == null + ? "master" + : "region " + ac.getRegion().getRegionInfo().getRegionNameAsString(); + } + // Copied from org.apache.hadoop.hbase.security.access.SecureTestUtil because it's not visible // there private static Map getAuthManagerMTimes(MiniHBaseCluster cluster) { @@ -1840,17 +1853,16 @@ public boolean evaluate() { Map mtimes = getAuthManagerMTimes(util.getHBaseCluster()); for (Map.Entry e : mtimes.entrySet()) { if (!oldMTimes.containsKey(e.getKey())) { - LOGGER.error("Snapshot of AccessController state does not include instance on region " - + e.getKey().getRegion().getRegionInfo().getRegionNameAsString()); + LOGGER.error("Snapshot of AccessController state does not include instance on " + + describe(e.getKey())); // Error out the predicate, we will try again return false; } long old = oldMTimes.get(e.getKey()); long now = e.getValue(); if (now <= old) { - LOGGER.info("AccessController on region " - + e.getKey().getRegion().getRegionInfo().getRegionNameAsString() - + " has not updated: mtime=" + now); + LOGGER.info( + "AccessController on " + describe(e.getKey()) + " has not updated: mtime=" + now); return false; } }