commit 4e640984e2a744431312c6ffd1535a2a231c8cdd Author: Daniel Dai Date: Thu Sep 3 21:30:40 2015 -0700 HIVE-11731: Exclude hbase-metastore in itests for hadoop-1 diff --git a/itests/hive-unit/pom.xml b/itests/hive-unit/pom.xml index 26b5751..5295840 100644 --- a/itests/hive-unit/pom.xml +++ b/itests/hive-unit/pom.xml @@ -173,6 +173,20 @@ hadoop-1 + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + **/metastore/hbase/** + + + + + org.apache.hadoop diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/HBaseIntegrationTests.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/HBaseIntegrationTests.java index c369058..02e481a 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/HBaseIntegrationTests.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/HBaseIntegrationTests.java @@ -64,18 +64,7 @@ protected static void startMiniCluster() throws Exception { utility.startMiniCluster(); conf = new HiveConf(utility.getConfiguration(), HBaseIntegrationTests.class); admin = utility.getHBaseAdmin(); - for (String tableName : HBaseReadWrite.tableNames) { - List families = HBaseReadWrite.columnFamilies.get(tableName); - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); - for (byte[] family : families) { - HColumnDescriptor columnDesc = new HColumnDescriptor(family); - if (testingTephra) columnDesc.setMaxVersions(Integer.MAX_VALUE); - desc.addFamily(columnDesc); - } - if (testingTephra) desc.addCoprocessor(TransactionProcessor.class.getName()); - admin.createTable(desc); - } - admin.close(); + HBaseStoreTestUtil.initHBaseMetastore(admin, null); } protected static void shutdownMiniCluster() throws Exception { diff --git a/itests/qtest/pom.xml b/itests/qtest/pom.xml index 122e3f6..739d06a 100644 --- a/itests/qtest/pom.xml +++ b/itests/qtest/pom.xml @@ -80,6 +80,13 @@ org.apache.hive + hive-it-unit + ${project.version} + tests + test + + + org.apache.hive hive-it-util ${project.version} test diff --git a/itests/util/pom.xml b/itests/util/pom.xml index b0818d6..fdab72c 100644 --- a/itests/util/pom.xml +++ b/itests/util/pom.xml @@ -97,6 +97,20 @@ hadoop-1 + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + **/metastore/hbase/** + + + + + org.apache.hadoop @@ -120,6 +134,12 @@ org.apache.hbase + hbase-common + ${hbase.hadoop1.version} + tests + + + org.apache.hbase hbase-server ${hbase.hadoop1.version} diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/metastore/hbase/HBaseStoreTestUtil.java b/itests/util/src/main/java/org/apache/hadoop/hive/metastore/hbase/HBaseStoreTestUtil.java new file mode 100644 index 0000000..1f42007 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/metastore/hbase/HBaseStoreTestUtil.java @@ -0,0 +1,45 @@ +/** + * 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.hive.metastore.hbase; + +import java.util.List; + +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.HBaseAdmin; +import org.apache.hadoop.hive.conf.HiveConf; + +public class HBaseStoreTestUtil { + public static void initHBaseMetastore(HBaseAdmin admin, HiveConf conf) throws Exception { + for (String tableName : HBaseReadWrite.tableNames) { + List families = HBaseReadWrite.columnFamilies.get(tableName); + HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + for (byte[] family : families) { + HColumnDescriptor columnDesc = new HColumnDescriptor(family); + desc.addFamily(columnDesc); + } + admin.createTable(desc); + } + admin.close(); + if (conf != null) { + HBaseReadWrite.getInstance(conf); + } + } +} \ No newline at end of file diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index 70df41e..24a85cf 100644 --- a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hive.ql; -import static org.apache.hadoop.hive.metastore.MetaStoreUtils.DEFAULT_DATABASE_COMMENT; import static org.apache.hadoop.hive.metastore.MetaStoreUtils.DEFAULT_DATABASE_NAME; import java.io.BufferedInputStream; @@ -67,9 +66,6 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; import org.apache.hadoop.hive.cli.CliDriver; @@ -81,9 +77,7 @@ import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; import org.apache.hadoop.hive.metastore.MetaStoreUtils; -import org.apache.hadoop.hive.metastore.Warehouse; import org.apache.hadoop.hive.metastore.api.Index; -import org.apache.hadoop.hive.metastore.hbase.HBaseReadWrite; import org.apache.hadoop.hive.ql.exec.FunctionRegistry; import org.apache.hadoop.hive.ql.exec.Task; import org.apache.hadoop.hive.ql.exec.Utilities; @@ -357,19 +351,14 @@ private void startMiniHBaseCluster() throws Exception { utility = new HBaseTestingUtility(); utility.startMiniCluster(); conf = new HiveConf(utility.getConfiguration(), Driver.class); - conf = new HiveConf(utility.getConfiguration(), Driver.class); HBaseAdmin admin = utility.getHBaseAdmin(); - for (String tableName : HBaseReadWrite.tableNames) { - List families = HBaseReadWrite.columnFamilies.get(tableName); - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); - for (byte[] family : families) { - HColumnDescriptor columnDesc = new HColumnDescriptor(family); - desc.addFamily(columnDesc); - } - admin.createTable(desc); - } - admin.close(); - HBaseReadWrite.getInstance(conf); + // Need to use reflection here to make compilation pass since HBaseIntegrationTests + // is not compiled in hadoop-1. All HBaseMetastore tests run under hadoop-2, so this + // guarantee HBaseIntegrationTests exist when we hitting this code path + java.lang.reflect.Method initHBaseMetastoreMethod = Class.forName( + "org.apache.hadoop.hive.metastore.hbase.HBaseStoreTestUtil") + .getMethod("initHBaseMetastore", HBaseAdmin.class, HiveConf.class); + initHBaseMetastoreMethod.invoke(null, admin, conf); } public QTestUtil(String outDir, String logDir, MiniClusterType clusterType, diff --git a/metastore/bin/.gitignore b/metastore/bin/.gitignore deleted file mode 100644 index 0e4bba6..0000000 --- a/metastore/bin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/scripts/ -/src/