You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sh...@apache.org on 2024/03/30 01:58:18 UTC

(phoenix) branch PHOENIX-6883-feature updated: PHOENIX-7069 disable feature in Permission ITs using HBASE-28391 (#1863)

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

shahrs87 pushed a commit to branch PHOENIX-6883-feature
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/PHOENIX-6883-feature by this push:
     new 55d9029789 PHOENIX-7069 disable feature in Permission ITs using HBASE-28391 (#1863)
55d9029789 is described below

commit 55d9029789e60bcdab9652be1040a5d94784b316
Author: palash <pa...@gmail.com>
AuthorDate: Fri Mar 29 18:58:13 2024 -0700

    PHOENIX-7069 disable feature in Permission ITs using HBASE-28391 (#1863)
---
 .../apache/phoenix/end2end/BasePermissionsIT.java  | 50 +++++++++++++++++++++-
 .../java/org/apache/phoenix/query/BaseTest.java    |  2 +-
 2 files changed, 50 insertions(+), 2 deletions(-)

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 363f672537..d7aea5a252 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
@@ -16,6 +16,7 @@
  */
 package org.apache.phoenix.end2end;
 
+import org.apache.hadoop.hbase.util.VersionInfo;
 import org.apache.phoenix.thirdparty.com.google.common.base.Joiner;
 import org.apache.phoenix.thirdparty.com.google.common.base.Throwables;
 import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
@@ -145,6 +146,7 @@ public abstract class BasePermissionsIT extends BaseTest {
     private static final int NUM_RECORDS = 5;
 
     boolean isNamespaceMapped;
+    boolean isReadAccessEnabledForListDecomRs;
 
     private String schemaName;
     private String tableName;
@@ -159,6 +161,7 @@ public abstract class BasePermissionsIT extends BaseTest {
     BasePermissionsIT(final boolean isNamespaceMapped) throws Exception {
         this.isNamespaceMapped = isNamespaceMapped;
         this.tableName = generateUniqueName();
+        isReadAccessEnabledForListDecomRs = isReadAccessEnabledForListDecomRs();
     }
 
     static void initCluster(boolean isNamespaceMapped) throws Exception {
@@ -179,11 +182,47 @@ public abstract class BasePermissionsIT extends BaseTest {
         configureNamespacesOnServer(config, isNamespaceMapped);
         configureStatsConfigurations(config);
         config.setBoolean(LocalHBaseCluster.ASSIGN_RANDOM_PORTS, true);
-
+        setPhoenixRegionServerEndpoint(config);
         testUtil.startMiniCluster(1);
         superUser1 = User.createUserForTesting(config, SUPER_USER, new String[0]);
         superUser2 = User.createUserForTesting(config, "superUser2", new String[0]);
 
+        /**
+         * CQSI initialization needs to make an Admin API call to fetch a list of live region servers.
+         * Permissions were relaxed for that API call in HBASE-28391.
+         * Disable metadata caching re-design on server if API call needs ADMIN access.
+         */
+        if (!isReadAccessEnabledForListDecomRs()) {
+            config.setLong(QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, 0L);
+            config.setBoolean(QueryServices.LAST_DDL_TIMESTAMP_VALIDATION_ENABLED, false);
+            config.setBoolean(QueryServices.PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED, false);
+        }
+    }
+
+    // See https://issues.apache.org/jira/browse/HBASE-28391
+    private static boolean isReadAccessEnabledForListDecomRs() {
+        // true for 2.4.18+, 2.5.8+
+        String hbaseVersion = VersionInfo.getVersion();
+        String[] versionArr = hbaseVersion.split("\\.");
+        int majorVersion = Integer.parseInt(versionArr[0]);
+        int minorVersion = Integer.parseInt(versionArr[1]);
+        int patchVersion = Integer.parseInt(versionArr[2].split("-hadoop")[0]);
+        if (majorVersion > 2) {
+            return true;
+        }
+        if (majorVersion < 2) {
+            return false;
+        }
+        if (minorVersion > 5) {
+            return true;
+        }
+        if (minorVersion < 4) {
+            return false;
+        }
+        if (minorVersion == 4) {
+            return patchVersion >= 18;
+        }
+        return patchVersion >= 8;
     }
 
     @Before
@@ -341,6 +380,15 @@ public abstract class BasePermissionsIT extends BaseTest {
             props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
         }
         props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped));
+        /**
+         * CQSI initialization needs to make an Admin API call to fetch a list of live region servers.
+         * Permissions were relaxed for that API call in HBASE-28391.
+         * Disable metadata caching re-design on client side if API call needs ADMIN access.
+         */
+        if (!isReadAccessEnabledForListDecomRs) {
+            props.put(QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, Long.toString(0L));
+            props.put(QueryServices.LAST_DDL_TIMESTAMP_VALIDATION_ENABLED, Boolean.toString(false));
+        }
         return props;
     }
 
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index 341b808479..9018246cd5 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@ -650,7 +650,7 @@ public abstract class BaseTest {
         PhoenixRegionServerEndpoint by default, if some other regionserver coprocs
         are not already present.
      */
-    private static void setPhoenixRegionServerEndpoint(Configuration conf) {
+    protected static void setPhoenixRegionServerEndpoint(Configuration conf) {
         String value = conf.get(REGIONSERVER_COPROCESSOR_CONF_KEY);
         if (value == null) {
             value = PhoenixRegionServerEndpointTestImpl.class.getName();