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

chinmayskulkarni pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/master by this push:
     new c318925  PHOENIX-5607 (Addendum) Client-server backward compatibility 
tests
c318925 is described below

commit c31892589147815b89220a89253c54e3eaf70d13
Author: Sandeep Guggilam <sguggi...@sandeepg-ltm.internal.salesforce.com>
AuthorDate: Tue Mar 17 13:06:10 2020 -0700

    PHOENIX-5607 (Addendum) Client-server backward compatibility tests
    
    Signed-off-by: Chinmay Kulkarni <chinmayskulka...@apache.org>
---
 .../phoenix/end2end/BackwardCompatibilityIT.java   | 34 ++++++++++++++++++++--
 .../it/resources/compatible_client_versions.json   | 10 +++++++
 phoenix-core/src/it/scripts/execute_query.sh       |  6 ++--
 .../phoenix/coprocessor/MetaDataProtocol.java      |  3 --
 4 files changed, 45 insertions(+), 8 deletions(-)

diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
index dfa0032..ae5dc38 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
@@ -38,6 +38,8 @@ import java.sql.ResultSetMetaData;
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.curator.shaded.com.google.common.collect.Lists;
 import org.apache.hadoop.conf.Configuration;
@@ -46,6 +48,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.util.VersionInfo;
 import org.apache.phoenix.coprocessor.MetaDataProtocol;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
 import org.apache.phoenix.jdbc.PhoenixDriver;
@@ -62,6 +65,11 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.stream.JsonReader;
+
 /**
  * This class is meant for testing all compatible client versions 
  * against the current server version. It runs SQL queries with given 
@@ -74,6 +82,8 @@ public class BackwardCompatibilityIT {
 
     private static final String SQL_DIR = "src/it/resources/sql_files/";
     private static final String RESULT_DIR = "src/it/resources/gold_files/";
+    private static final String COMPATIBLE_CLIENTS_JSON =
+            "src/it/resources/compatible_client_versions.json";
     private static final String RESULT_PREFIX = "result_";
     private static final String SQL_EXTENSION = ".sql";
     private static final String TEXT_EXTENSION = ".txt";
@@ -95,8 +105,8 @@ public class BackwardCompatibilityIT {
     }
 
     @Parameters(name = "BackwardCompatibilityIT_compatibleClientVersion={0}")
-    public static synchronized Collection<String> data() {
-        return MetaDataProtocol.COMPATIBLE_CLIENT_VERSIONS;
+    public static synchronized Collection<String> data() throws Exception {
+        return computeClientVersions();
     }
 
     @Before
@@ -119,6 +129,26 @@ public class BackwardCompatibilityIT {
             hbaseTestUtil.shutdownMiniCluster();
         }
     }
+    
+    private static List<String> computeClientVersions() throws Exception {
+        String hbaseVersion = VersionInfo.getVersion();
+        Pattern p = Pattern.compile("\\d+\\.\\d+");
+        Matcher m = p.matcher(hbaseVersion);
+        String hbaseProfile = null;
+        if (m.find()) {
+            hbaseProfile = m.group();
+        }
+        List<String> clientVersions = Lists.newArrayList();
+        JsonParser jsonParser = new JsonParser();
+        JsonReader jsonReader =
+                new JsonReader(new FileReader(COMPATIBLE_CLIENTS_JSON));
+        JsonObject jsonObject =
+                jsonParser.parse(jsonReader).getAsJsonObject();
+        for (JsonElement clientVersion : 
jsonObject.get(hbaseProfile).getAsJsonArray()) {
+            clientVersions.add(clientVersion.getAsString() + "-HBase-" + 
hbaseProfile);
+        }
+        return clientVersions;
+    }
 
     /**
      * Scenario: 
diff --git a/phoenix-core/src/it/resources/compatible_client_versions.json 
b/phoenix-core/src/it/resources/compatible_client_versions.json
new file mode 100644
index 0000000..6feabf5
--- /dev/null
+++ b/phoenix-core/src/it/resources/compatible_client_versions.json
@@ -0,0 +1,10 @@
+{
+    "_comment": "Lists all phoenix compatible client versions against the 
current branch version for a given hbase profile \
+                 If hbase profile is 1.3, phoenix client versions 4.14.3 and 
4.15.0 are tested against current branch version",    
+    "1.3": ["4.14.3", "4.15.0"],
+    "1.4": ["4.14.3", "4.15.0"],
+    "1.5": ["4.15.0"],
+    "2.0": ["5.1.0"],
+    "2.1": ["5.1.0"],
+    "2.2": ["5.1.0"]
+}
\ No newline at end of file
diff --git a/phoenix-core/src/it/scripts/execute_query.sh 
b/phoenix-core/src/it/scripts/execute_query.sh
index 8cfdde6..7dba6e9 100644
--- a/phoenix-core/src/it/scripts/execute_query.sh
+++ b/phoenix-core/src/it/scripts/execute_query.sh
@@ -30,11 +30,11 @@ if [ -n $maven_home ]; then
    export PATH=$maven_home/bin:$PATH
 fi
 
-mvn dependency:get -Dartifact=org.apache.phoenix:phoenix-core:$client_version
-mvn dependency:copy -Dartifact=org.apache.phoenix:phoenix-core:$client_version 
\
+mvn dependency:get -Dartifact=org.apache.phoenix:phoenix-client:$client_version
+mvn dependency:copy 
-Dartifact=org.apache.phoenix:phoenix-client:$client_version \
 -DoutputDirectory=$tmp_dir
 
-phoenix_client_jar=$tmp_dir/phoenix-core-$client_version.jar
+phoenix_client_jar=$tmp_dir/phoenix-client-$client_version.jar
 java -cp ".:$phoenix_client_jar" sqlline.SqlLine -d 
org.apache.phoenix.jdbc.PhoenixDriver \
 -u jdbc:phoenix:$zk_url -n none -p none --color=false --fastConnect=true 
--outputformat=csv \
 --silent=true --verbose=false --isolation=TRANSACTION_READ_COMMITTED 
--run=$sqlfile &> $resultfile
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
index 17e93c4..9fb308f 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
@@ -18,7 +18,6 @@
 package org.apache.phoenix.coprocessor;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -151,8 +150,6 @@ public abstract class MetaDataProtocol extends 
MetaDataService {
     }
     
     public static final String CURRENT_CLIENT_VERSION = PHOENIX_MAJOR_VERSION 
+ "." + PHOENIX_MINOR_VERSION + "." + PHOENIX_PATCH_NUMBER;
-    public static final List<String> COMPATIBLE_CLIENT_VERSIONS =
-            Arrays.asList("5.1.0-HBase-2.0");
      
     
     // TODO: pare this down to minimum, as we don't need duplicates for both 
table and column errors, nor should we need

Reply via email to