PHOENIX-5829 Make it possible to build/test queryserver against all supported versions

also fix some regressions in python scripts and assembly

Closes #46
diff --git a/README.md b/README.md
index c54986f..a2783df 100644
--- a/README.md
+++ b/README.md
@@ -44,14 +44,32 @@
 
 ### Bundling a Phoenix Client
 
-To build a release of PQS which packages a specific version of Phoenix, enable the `package-phoenix-client` profile
-and specify properties to indicate a specific Phoenix version.
+To build a release of PQS which packages a specific version of Phoenix, specify the `package-phoenix-client` system property
+and specify the `phoenix.version` system property to indicate a specific Phoenix version.
 
-By default, PQS will package the same version of Phoenix used for build/test. This version is controlled by the system
-property `phoenix.version` system property. Depending on the version of Phoenix, you may also be required to
-use the `phoenix.hbase.classifier` system property to identify the correct version of Phoenix built against
-the version of HBase of your choosing.
+PQS will package the same version of Phoenix used for build/test. This version is controlled by the
+ `phoenix.version` system property.
 
 ```
-$ mvn package -Dpackage.phoenix.client -Dphoenix.version=5.1.0-SNAPSHOT -Dphoenix.hbase.classifier=hbase-2.2
+$ mvn package -Dpackage.phoenix.client -Dphoenix.version=5.1.0-SNAPSHOT
+```
+
+### Running integration tests
+
+`mvn package` will run the unit tests while building, but it will not run the integration test suite.
+
+The IT suite is run when executing `mvn install` or `mvn verify`. The Phoenix version specified
+with `phoenix.version` is used for running the integration tests.
+
+When specifying `phoenix.version`, also specify the HBase version to be used
+for integration testing by activating the corresponding `hbase<minor.major>` profile.
+
+When using a Phoenix 5.x version, activate the `hbase-2.x` profile in addition to the
+profile for the minor 2.x version.
+
+```
+$ mvn verify -Dpackage.phoenix.client -Dphoenix.version=4.16.0-SNAPSHOT -Phbase-1.3
+```
+```
+$ mvn install -Dpackage.phoenix.client -Dphoenix.version=5.1.0-SNAPSHOT -Phbase-2.1 -Phbase-2.x
 ```
diff --git a/bin/phoenix_queryserver_utils.py b/bin/phoenix_queryserver_utils.py
index c5b6a78..831b955 100755
--- a/bin/phoenix_queryserver_utils.py
+++ b/bin/phoenix_queryserver_utils.py
@@ -78,8 +78,8 @@
 def setPath():
     PHOENIX_CLIENT_JAR_PATTERN = "phoenix-client-*.jar"
     OLD_PHOENIX_CLIENT_JAR_PATTERN = "phoenix-*[!n]-client.jar"
-    PHOENIX_THIN_CLIENT_JAR_PATTERN = "queryserver-client-*.jar"
-    PHOENIX_QUERYSERVER_JAR_PATTERN = "queryserver-[!c]*.jar"
+    PHOENIX_THIN_CLIENT_JAR_PATTERN = "phoenix-queryserver-client-*.jar"
+    PHOENIX_QUERYSERVER_JAR_PATTERN = "phoenix-queryserver-[!c]*.jar"
     PHOENIX_LOADBALANCER_JAR_PATTERN = "load-balancer-*[!t][!e][!s][!t][!s].jar"
     SQLLINE_WITH_DEPS_PATTERN = "sqlline-*-jar-with-dependencies.jar"
 
diff --git a/phoenix-queryserver-assembly/pom.xml b/phoenix-queryserver-assembly/pom.xml
index 3b45559..3989d14 100644
--- a/phoenix-queryserver-assembly/pom.xml
+++ b/phoenix-queryserver-assembly/pom.xml
@@ -63,7 +63,7 @@
                             <descriptors>
                                 <descriptor>src/assembly/cluster.xml</descriptor>
                             </descriptors>
-                            <finalName>${project.parent.artifactId}-${project.version}</finalName>
+                            <finalName>phoenix-queryserver-${project.version}</finalName>
                             <tarLongFileMode>posix</tarLongFileMode>
                             <appendAssemblyId>false</appendAssemblyId>
                         </configuration>
@@ -104,7 +104,6 @@
                 <dependency>
                     <groupId>org.apache.phoenix</groupId>
                     <artifactId>phoenix-client</artifactId>
-                    <classifier>${phoenix.hbase.classifier}</classifier>
                 </dependency>
             </dependencies>
         </profile>
diff --git a/phoenix-queryserver-assembly/src/assembly/cluster.xml b/phoenix-queryserver-assembly/src/assembly/cluster.xml
index d55a63d..58ce02f 100644
--- a/phoenix-queryserver-assembly/src/assembly/cluster.xml
+++ b/phoenix-queryserver-assembly/src/assembly/cluster.xml
@@ -38,14 +38,14 @@
             <directory>${project.basedir}/../phoenix-queryserver/target</directory>
             <outputDirectory>${project.parent.artifactId}-${project.parent.version}/</outputDirectory>
             <includes>
-                <include>queryserver-${project.parent.version}.jar</include>
+                <include>phoenix-queryserver-${project.parent.version}.jar</include>
             </includes>
         </fileSet>
         <fileSet>
             <directory>${project.basedir}/../phoenix-queryserver-client/target</directory>
             <outputDirectory>${project.parent.artifactId}-${project.parent.version}/</outputDirectory>
             <includes>
-                <include>queryserver-client-${project.parent.version}.jar</include>
+                <include>phoenix-queryserver-client-${project.parent.version}.jar</include>
             </includes>
         </fileSet>
         <fileSet>
@@ -65,7 +65,7 @@
         <unpack>false</unpack>
         <outputDirectory>${project.parent.artifactId}-${project.parent.version}/</outputDirectory>
         <includes>
-          <include>org.apache.phoenix:phoenix-client:jar:${phoenix.hbase.classifier}</include>
+          <include>org.apache.phoenix:phoenix-client:jar</include>
         </includes>
       </dependencySet>
     </dependencySets>
diff --git a/phoenix-queryserver-it/pom.xml b/phoenix-queryserver-it/pom.xml
index 8b0552d..45684e9 100644
--- a/phoenix-queryserver-it/pom.xml
+++ b/phoenix-queryserver-it/pom.xml
@@ -77,31 +77,15 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <configuration>
-          <ignoredUnusedDeclaredDependencies>
-            <!-- false positive - Why ? -->
-            <ignoredUnusedDeclaredDependency>
-              org.slf4j:slf4j-api
-            </ignoredUnusedDeclaredDependency>
-            <!-- Maven has no transitive test dependencies -->
-            <ignoredUnusedDeclaredDependency>
-              org.apache.hbase:hbase-testing-util
-            </ignoredUnusedDeclaredDependency>
-            <ignoredUnusedDeclaredDependency>
-              org.apache.hbase:hbase-it
-            </ignoredUnusedDeclaredDependency>
-            <ignoredUnusedDeclaredDependency>
-              org.apache.hadoop:hadoop-hdfs:test-jar
-            </ignoredUnusedDeclaredDependency>
-            <ignoredUnusedDeclaredDependency>
-              org.apache.hadoop:hadoop-common:test-jar
-            </ignoredUnusedDeclaredDependency>
-          </ignoredUnusedDeclaredDependencies>
+          <!-- dependency:analyze is quite useless for hadoop test dependencies -->
+          <ignoreNonCompile>true</ignoreNonCompile>
         </configuration>
       </plugin>
     </plugins>
   </build>
 
   <dependencies>
+    <!-- for tests -->
     <dependency>
       <groupId>org.apache.phoenix</groupId>
       <artifactId>phoenix-queryserver</artifactId>
@@ -113,9 +97,12 @@
       <artifactId>phoenix-queryserver-client</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <!-- Use the actual shaded phoenix-client for the ITs -->
+    <!-- We still need unshaded Hadoop+Hbase deps for running the minicluster -->
     <dependency>
       <groupId>org.apache.phoenix</groupId>
-      <artifactId>phoenix-core</artifactId>
+      <artifactId>phoenix-client</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -124,11 +111,11 @@
       <scope>test</scope>
       <classifier>tests</classifier>
     </dependency>
-    <!--dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-security</artifactId>
+    <dependency>
+      <groupId>org.apache.phoenix</groupId>
+      <artifactId>phoenix-queryserver-orchestrator</artifactId>
       <scope>test</scope>
-    </dependency-->
+    </dependency>
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
@@ -139,11 +126,6 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
-    <!--dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <scope>test</scope>
-    </dependency-->
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-common</artifactId>
@@ -157,16 +139,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>
-      <artifactId>hbase-client</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hbase</groupId>
-      <artifactId>hbase-server</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-server</artifactId>
       <type>test-jar</type>
       <scope>test</scope>
@@ -178,22 +150,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
-      <artifactId>hadoop-auth</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-minikdc</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-hdfs</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hadoop</groupId>
-      <artifactId>hadoop-hdfs</artifactId>
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
@@ -213,5 +175,85 @@
       <artifactId>bcprov-jdk15</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
+
+  <profiles>
+    <profile>
+      <id>hbase-2.x</id>
+      <properties>
+        <hbase.version>2.1.9</hbase.version>
+        <hadoop.version>3.0.3</hadoop.version>
+      </properties>
+      <dependencies>
+        <dependency>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-server</artifactId>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-security</artifactId>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-util</artifactId>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+    <!-- These are only to be used if phoenix was compiled with a non-default
+      -Dhbase.profile -->
+    <profile>
+      <id>hbase-1.3</id>
+      <properties>
+        <hbase.version>1.3.5</hbase.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>hbase-1.4</id>
+      <properties>
+        <hbase.version>1.4.10</hbase.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>hbase-1.5</id>
+      <properties>
+        <hbase.version>1.5.0</hbase.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>hbase-1.6</id>
+      <properties>
+        <hbase.version>1.6.0</hbase.version>
+        <hadoop.version>2.8.5</hadoop.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>hbase-2.1</id>
+      <properties>
+        <hbase.version>2.1.9</hbase.version>
+        <hadoop.version>3.0.3</hadoop.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>hbase-2.2</id>
+      <properties>
+        <hbase.version>2.2.5</hbase.version>
+        <hadoop.version>3.1.2</hadoop.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>hbase-2.3</id>
+      <properties>
+        <hbase.version>2.3.0</hbase.version>
+        <hadoop.version>3.1.2</hadoop.version>
+      </properties>
+    </profile>
+  </profiles>
 </project>
diff --git a/phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java b/phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java
index bab190c..f498683 100644
--- a/phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java
+++ b/phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java
@@ -48,7 +48,6 @@
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.LocalHBaseCluster;
-import org.apache.hadoop.hbase.client.TestHCM.SleepAndFailFirstTime;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
 import org.apache.hadoop.hbase.security.token.TokenProvider;
diff --git a/phoenix-queryserver-orchestrator/src/it/java/org/apache/phoenix/tool/ParameterizedPhoenixCanaryToolIT.java b/phoenix-queryserver-it/src/it/java/org/apache/phoenix/tool/ParameterizedPhoenixCanaryToolIT.java
similarity index 100%
rename from phoenix-queryserver-orchestrator/src/it/java/org/apache/phoenix/tool/ParameterizedPhoenixCanaryToolIT.java
rename to phoenix-queryserver-it/src/it/java/org/apache/phoenix/tool/ParameterizedPhoenixCanaryToolIT.java
diff --git a/phoenix-queryserver-orchestrator/pom.xml b/phoenix-queryserver-orchestrator/pom.xml
index 68452aa..7009330 100644
--- a/phoenix-queryserver-orchestrator/pom.xml
+++ b/phoenix-queryserver-orchestrator/pom.xml
@@ -56,10 +56,6 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.apache.phoenix</groupId>
-            <artifactId>phoenix-core</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
@@ -103,12 +99,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.phoenix</groupId>
-            <artifactId>phoenix-core</artifactId>
-            <classifier>tests</classifier>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.hbase</groupId>
             <artifactId>hbase-it</artifactId>
            <type>test-jar</type>
@@ -120,5 +110,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-
 </project>
diff --git a/phoenix-queryserver/pom.xml b/phoenix-queryserver/pom.xml
index d5be630..441d01b 100644
--- a/phoenix-queryserver/pom.xml
+++ b/phoenix-queryserver/pom.xml
@@ -222,12 +222,12 @@
     <!-- for tests -->
     <dependency>
       <groupId>org.apache.phoenix</groupId>
-      <artifactId>phoenix-queryserver-client</artifactId>
+      <artifactId>phoenix-client</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.phoenix</groupId>
-      <artifactId>phoenix-core</artifactId>
+      <artifactId>phoenix-queryserver-client</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/pom.xml b/pom.xml
index de7b1f2..c57292f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,7 +72,7 @@
 
         <!-- Hadoop/Hbase Versions -->
         <hbase.version>1.4.10</hbase.version>
-        <hadoop-two.version>2.7.5</hadoop-two.version>
+        <hadoop.version>2.7.5</hadoop.version>
 
         <!-- Dependency versions -->
         <zookeeper.version>3.4.10</zookeeper.version>
@@ -336,6 +336,11 @@
 
     <dependencyManagement>
         <dependencies>
+            <dependency>
+                <groupId>org.apache.phoenix</groupId>
+                <artifactId>phoenix-client</artifactId>
+                <version>${phoenix.version}</version>
+            </dependency>
 
             <!-- Intra-project dependencies -->
             <dependency>
@@ -384,7 +389,7 @@
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-common</artifactId>
-                <version>${hadoop-two.version}</version>
+                <version>${hadoop.version}</version>
                 <exclusions>
                     <exclusion>
                         <groupId>org.xerial.snappy</groupId>
@@ -399,7 +404,7 @@
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-auth</artifactId>
-                <version>${hadoop-two.version}</version>
+                <version>${hadoop.version}</version>
             </dependency>
 
             <!-- General Dependencies -->
@@ -507,8 +512,15 @@
                 <groupId>org.apache.phoenix</groupId>
                 <artifactId>queryserver</artifactId>
                 <version>${project.version}</version>
+                <scope>test</scope>
                 <classifier>tests</classifier>
             </dependency>
+            <dependency>
+                <groupId>org.apache.phoenix</groupId>
+                <artifactId>phoenix-queryserver-orchestrator</artifactId>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
 
             <!-- Hbase test dependencies -->
             <dependency>
@@ -536,20 +548,20 @@
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-hdfs</artifactId>
-                <version>${hadoop-two.version}</version>
+                <version>${hadoop.version}</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-hdfs</artifactId>
-                <version>${hadoop-two.version}</version>
+                <version>${hadoop.version}</version>
                 <type>test-jar</type>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-common</artifactId>
-                <version>${hadoop-two.version}</version>
+                <version>${hadoop.version}</version>
                 <type>test-jar</type>
                 <scope>test</scope>
             </dependency>
@@ -589,7 +601,7 @@
             <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-minikdc</artifactId>
-                <version>${hadoop-two.version}</version>
+                <version>${hadoop.version}</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
@@ -600,28 +612,4 @@
             </dependency>
         </dependencies>
     </dependencyManagement>
-    <profiles>
-        <profile>
-            <id>package-phoenix-client</id>
-            <activation>
-              <property>
-                <name>package.phoenix.client</name>
-              </property>
-            </activation>
-            <properties>
-                <!-- Not necessary for Phoenix <4.16.0 -->
-                <phoenix.hbase.classifier></phoenix.hbase.classifier>
-            </properties>
-            <dependencyManagement>
-                <dependencies>
-                    <dependency>
-                        <groupId>org.apache.phoenix</groupId>
-                        <artifactId>phoenix-client</artifactId>
-                        <version>${phoenix.version}</version>
-                        <classifier>${phoenix.hbase.classifier}</classifier>
-                    </dependency>
-                </dependencies>
-            </dependencyManagement>
-        </profile>
-    </profiles>
 </project>