http://git-wip-us.apache.org/repos/asf/phoenix/blob/f0c2ed4e/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixIndexRpcSchedulerFactoryTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixIndexRpcSchedulerFactoryTest.java b/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixIndexRpcSchedulerFactoryTest.java deleted file mode 100644 index 7d08c0d..0000000 --- a/phoenix-core/src/test/java/org/apache/hadoop/hbase/regionserver/PhoenixIndexRpcSchedulerFactoryTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * 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.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory; -import org.apache.phoenix.query.QueryServices; -import org.junit.Test; - -public class PhoenixIndexRpcSchedulerFactoryTest { - - @Test - public void ensureInstantiation() throws Exception { - Configuration conf = new Configuration(false); - conf.setClass(RSRpcServices.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS, - PhoenixIndexRpcSchedulerFactory.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(RSRpcServices.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS, - SimpleRpcSchedulerFactory.class); - Object o = rpcSchedulerFactoryClass.newInstance(); - assertTrue(o instanceof PhoenixIndexRpcSchedulerFactory); - } 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 priority ranges inside the hbase ranges - * @throws Exception - */ - @Test - public void testValidateIndexPriorityRanges() throws Exception { - Configuration conf = new Configuration(false); - // standard configs should be fine - PhoenixIndexRpcSchedulerFactory factory = new PhoenixIndexRpcSchedulerFactory(); - factory.create(conf, null); - - setMinMax(conf, 0, 4); - factory.create(conf, null); - - setMinMax(conf, 201, 202); - factory.create(conf, null); - - setMinMax(conf, 102, 101); - try { - factory.create(conf, null); - fail("Should not have allowed max less than min"); - } catch (IllegalArgumentException e) { - // expected - } - - setMinMax(conf, 5, 6); - try { - factory.create(conf, null); - fail("Should not have allowed min in range"); - } catch (IllegalArgumentException e) { - // expected - } - - setMinMax(conf, 6, 60); - try { - factory.create(conf, null); - fail("Should not have allowed min/max in hbase range"); - } catch (IllegalArgumentException e) { - // expected - } - - setMinMax(conf, 6, 101); - try { - factory.create(conf, null); - fail("Should not have allowed in range"); - } catch (IllegalArgumentException e) { - // expected - } - } - - private void setMinMax(Configuration conf, int min, int max) { - conf.setInt(QueryServices.MIN_INDEX_PRIOIRTY_ATTRIB, min); - conf.setInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, max); - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/phoenix/blob/f0c2ed4e/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..eb28c8d --- /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(RSRpcServices.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(RSRpcServices.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, 1001, 1002); + factory.create(conf, null); + + // test priorities in HBase range + setPriorities(conf, 1, 201); + try { + factory.create(conf, null); + fail("Should not have allowed priorities in HBase range"); + } catch (IllegalArgumentException e) { + // expected + } + setPriorities(conf, 1001, 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, 1001, 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, 1001); + 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, 1001, 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, 1001); + 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/f0c2ed4e/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