Repository: phoenix
Updated Branches:
  refs/heads/4.3 eeff9bee3 -> 0b49b28f8


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b49b28f/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixRpcSchedulerFactoryTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixRpcSchedulerFactoryTest.java
 
b/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixRpcSchedulerFactoryTest.java
new file mode 100644
index 0000000..6b04c40
--- /dev/null
+++ 
b/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixRpcSchedulerFactoryTest.java
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.regionserver;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory;
+import org.apache.phoenix.query.QueryServices;
+import org.junit.Test;
+
+public class PhoenixRpcSchedulerFactoryTest {
+
+    @Test
+    public void ensureInstantiation() throws Exception {
+        Configuration conf = new Configuration(false);
+        conf.setClass(HRegionServer.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS,
+            PhoenixRpcSchedulerFactory.class, RpcSchedulerFactory.class);
+        // kinda lame that we copy the copy from the regionserver to do this 
and can't use a static
+        // method, but meh
+        try {
+            Class<?> rpcSchedulerFactoryClass =
+                    
conf.getClass(HRegionServer.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS,
+                        SimpleRpcSchedulerFactory.class);
+            Object o = rpcSchedulerFactoryClass.newInstance();
+            assertTrue(o instanceof PhoenixRpcSchedulerFactory);
+        } catch (InstantiationException e) {
+            assertTrue("Should not have got an exception when instantiing the 
rpc scheduler: " + e,
+                false);
+        } catch (IllegalAccessException e) {
+            assertTrue("Should not have got an exception when instantiing the 
rpc scheduler: " + e,
+                false);
+        }
+    }
+
+    /**
+     * Ensure that we can't configure the index and metadata priority ranges 
inside the hbase ranges
+     * @throws Exception
+     */
+    @Test
+    public void testValidateRpcPriorityRanges() throws Exception {
+        Configuration conf = new Configuration(false);
+        // standard configs should be fine
+        PhoenixRpcSchedulerFactory factory = new PhoenixRpcSchedulerFactory();
+        factory.create(conf, null);
+
+        // test priorities less than HBase range
+        setPriorities(conf, -4, -1);
+        factory.create(conf, null);
+
+        // test priorities greater than HBase range
+        setPriorities(conf, 101, 102);
+        factory.create(conf, null);
+
+        // test priorities in HBase range
+        setPriorities(conf, 1, 101);
+        try {
+            factory.create(conf, null);
+            fail("Should not have allowed priorities in HBase range");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        setPriorities(conf, 101, 1);
+        try {
+            factory.create(conf, null);
+            fail("Should not have allowed priorities in HBase range");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        
+        // test priorities in HBase range
+        setPriorities(conf, 101, HConstants.NORMAL_QOS);
+        try {
+            factory.create(conf, null);
+            fail("Should not have allowed priorities in HBase range");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        setPriorities(conf, HConstants.NORMAL_QOS, 101);
+        try {
+            factory.create(conf, null);
+            fail("Should not have allowed priorities in HBase range");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        
+        // test priorities in HBase range
+        setPriorities(conf, 101, HConstants.HIGH_QOS);
+        try {
+            factory.create(conf, null);
+            fail("Should not have allowed priorities in HBase range");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        setPriorities(conf, HConstants.HIGH_QOS, 101);
+        try {
+            factory.create(conf, null);
+            fail("Should not have allowed priorities in HBase range");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    private void setPriorities(Configuration conf, int indexPrioritymin, int 
metadataPriority) {
+        conf.setInt(QueryServices.INDEX_PRIOIRTY_ATTRIB, indexPrioritymin);
+        conf.setInt(QueryServices.METADATA_PRIOIRTY_ATTRIB, metadataPriority);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b49b28f/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
----------------------------------------------------------------------
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 e4ec56a..748ad19 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
@@ -457,7 +457,7 @@ public abstract class BaseTest {
     }
     
     private static final String ORG_ID = "00D300000000XHP";
-    private static final int NUM_SLAVES_BASE = 1;
+    protected static int NUM_SLAVES_BASE = 1;
     
     protected static String getZKClientPort(Configuration conf) {
         return conf.get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
@@ -531,9 +531,13 @@ public abstract class BaseTest {
     }
             
     protected static void setUpTestDriver(ReadOnlyProps props) throws 
Exception {
-        String url = checkClusterInitialized(props);
+        setUpTestDriver(props, props);
+    }
+    
+    protected static void setUpTestDriver(ReadOnlyProps serverProps, 
ReadOnlyProps clientProps) throws Exception {
+        String url = checkClusterInitialized(serverProps);
         if (driver == null) {
-            driver = initAndRegisterDriver(url, props);
+            driver = initAndRegisterDriver(url, clientProps);
         }
     }
 
@@ -557,7 +561,7 @@ public abstract class BaseTest {
         setUpConfigForMiniCluster(conf, overrideProps);
         utility = new HBaseTestingUtility(conf);
         try {
-            utility.startMiniCluster();
+            utility.startMiniCluster(NUM_SLAVES_BASE);
             // add shutdown hook to kill the mini cluster
             Runtime.getRuntime().addShutdownHook(new Thread() {
                 @Override

Reply via email to