Repository: hive Updated Branches: refs/heads/master 1593c10dd -> f9768af0e
HIVE-18771: Refactor tests, so only 1 MetaStore instance will be started per test class and test configuration (Peter Vary, reviewed by Sahil Takiar) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/f9768af0 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/f9768af0 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/f9768af0 Branch: refs/heads/master Commit: f9768af0e147539c52311643c8bcaa778483e051 Parents: 1593c10 Author: Peter Vary <pv...@cloudera.com> Authored: Fri Feb 23 09:08:32 2018 +0100 Committer: Peter Vary <pv...@cloudera.com> Committed: Fri Feb 23 09:08:32 2018 +0100 ---------------------------------------------------------------------- .../metastore/client/MetaStoreClientTest.java | 95 ++++++++++++++++++++ .../client/MetaStoreFactoryForTests.java | 8 +- .../client/TestAddAlterDropIndexes.java | 31 +------ .../metastore/client/TestAddPartitions.java | 32 +------ .../client/TestAddPartitionsFromPartSpec.java | 33 +------ .../metastore/client/TestAlterPartitions.java | 33 +------ .../metastore/client/TestAppendPartitions.java | 31 +------ .../hive/metastore/client/TestDatabases.java | 40 +-------- .../metastore/client/TestDropPartitions.java | 37 ++------ .../client/TestExchangePartitions.java | 33 +------ .../hive/metastore/client/TestFunctions.java | 31 +------ .../metastore/client/TestGetListIndexes.java | 31 +------ .../metastore/client/TestGetPartitions.java | 33 +------ .../hive/metastore/client/TestGetTableMeta.java | 32 +------ .../metastore/client/TestListPartitions.java | 33 +------ .../TestTablesCreateDropAlterTruncate.java | 36 ++------ .../metastore/client/TestTablesGetExists.java | 32 +------ .../hive/metastore/client/TestTablesList.java | 35 +------- 18 files changed, 139 insertions(+), 497 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java new file mode 100644 index 0000000..a0e9d32 --- /dev/null +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientTest.java @@ -0,0 +1,95 @@ +/* + * 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.client; + +import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Tests abstract class for running MetaStoreClient API tests. + */ +@RunWith(Parameterized.class) +@Category(MetastoreCheckinTest.class) +public abstract class MetaStoreClientTest { + private static final Logger LOG = LoggerFactory.getLogger(TestDatabases.class); + + // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) + // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a + // Then we should remove our own copy + private static Set<AbstractMetaStoreService> metaStoreServices = null; + + @Parameterized.Parameters(name = "{0}") + public static List<Object[]> getMetaStoreToTest() throws Exception { + List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); + metaStoreServices = result.stream() + .map(test -> (AbstractMetaStoreService)test[1]) + .collect(Collectors.toSet()); + return result; + } + + @BeforeClass + public static void startMetaStores() { + startMetaStores(new HashMap<MetastoreConf.ConfVars, String>(), new HashMap<String, String>()); + } + + /** + * Utility method, which can be used to start MetaStore instances with specific configurations + * different from the default. + * @param msConf Specific MetaStore configuration values + * @param extraConf Specific other configuration values + */ + static void startMetaStores(Map<MetastoreConf.ConfVars, String> msConf, + Map<String, String> extraConf) { + for(AbstractMetaStoreService metaStoreService : metaStoreServices) { + try { + metaStoreService.start(msConf, extraConf); + } catch(Exception e) { + // Catch the exceptions, so every other metastore could be stopped as well + // Log it, so at least there is a slight possibility we find out about this :) + LOG.error("Error starting MetaStoreService", e); + } + } + } + + @AfterClass + public static void stopMetaStores() { + for(AbstractMetaStoreService metaStoreService : metaStoreServices) { + try { + metaStoreService.stop(); + } catch(Exception e) { + // Catch the exceptions, so every other metastore could be stopped as well + // Log it, so at least there is a slight possibility we find out about this :) + LOG.error("Error stopping MetaStoreService", e); + } + } + } +} http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java index e723f60..84c187b 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java @@ -20,9 +20,8 @@ package org.apache.hadoop.hive.metastore.client; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hive.metastore.DefaultPartitionExpressionProxy; +import org.apache.hadoop.hive.metastore.MetaStoreTestUtils; import org.apache.hadoop.hive.metastore.conf.MetastoreConf; -import org.apache.hadoop.hive.metastore.events.EventCleanerTask; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.hadoop.hive.metastore.minihms.MiniHMS; @@ -60,10 +59,7 @@ public final class MetaStoreFactoryForTests { MetastoreConf.setLongVar(conf, MetastoreConf.ConfVars.BATCH_RETRIEVE_MAX, 2); MetastoreConf.setLongVar(conf, MetastoreConf.ConfVars.LIMIT_PARTITION_REQUEST, DEFAULT_LIMIT_PARTITION_REQUEST); - MetastoreConf.setVar(conf, MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS, - DefaultPartitionExpressionProxy.class.getName()); - MetastoreConf.setVar(conf, MetastoreConf.ConfVars.TASK_THREADS_ALWAYS, - EventCleanerTask.class.getName()); + MetaStoreTestUtils.setConfForStandloneMode(conf); // Do this only on your own peril, and never in the production code conf.set("datanucleus.autoCreateTables", "false"); http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddAlterDropIndexes.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddAlterDropIndexes.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddAlterDropIndexes.java index d25b81e..2b8f297 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddAlterDropIndexes.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddAlterDropIndexes.java @@ -20,8 +20,6 @@ package org.apache.hadoop.hive.metastore.client; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.metastore.IMetaStoreClient; @@ -45,7 +43,6 @@ import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -58,11 +55,7 @@ import org.junit.runners.Parameterized; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestAddAlterDropIndexes { - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestAddAlterDropIndexes extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -72,28 +65,8 @@ public class TestAddAlterDropIndexes { private static final String INDEX_TABLE_NAME = TABLE_NAME + "__" + INDEX_NAME + "__"; private static final short MAX = -1; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestAddAlterDropIndexes(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestAddAlterDropIndexes(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java index f483ca8..4d9cb1b 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitions.java @@ -20,8 +20,6 @@ package org.apache.hadoop.hive.metastore.client; import java.util.ArrayList; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.metastore.IMetaStoreClient; @@ -43,7 +41,6 @@ import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -58,12 +55,7 @@ import com.google.common.collect.Lists; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestAddPartitions { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestAddPartitions extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -77,28 +69,8 @@ public class TestAddPartitions { private static final String MONTH_COL_NAME = "month"; private static final short MAX = -1; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestAddPartitions(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestAddPartitions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java index 919ba78..1122057 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java @@ -22,8 +22,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.metastore.IMetaStoreClient; @@ -49,7 +47,6 @@ import org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy; import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -64,12 +61,7 @@ import com.google.common.collect.Lists; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestAddPartitionsFromPartSpec { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestAddPartitionsFromPartSpec extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -84,29 +76,8 @@ public class TestAddPartitionsFromPartSpec { private static final int DEFAULT_CREATE_TIME = 123456; private static final short MAX = -1; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestAddPartitionsFromPartSpec(String name, AbstractMetaStoreService metaStore) - throws Exception { + public TestAddPartitionsFromPartSpec(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java index 31b3154..7f854ed 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java @@ -21,8 +21,6 @@ package org.apache.hadoop.hive.metastore.client; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; @@ -43,7 +41,6 @@ import org.apache.thrift.transport.TTransportException; import com.google.common.collect.Lists; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -62,13 +59,8 @@ import static org.junit.Assert.fail; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestAlterPartitions { - +public class TestAlterPartitions extends MetaStoreClientTest { public static final int NEW_CREATE_TIME = 123456789; - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -76,29 +68,8 @@ public class TestAlterPartitions { private static final String TABLE_NAME = "testparttable"; private static final List<String> PARTCOL_SCHEMA = Lists.newArrayList("yyyy", "mm", "dd"); - - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestAlterPartitions(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestAlterPartitions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAppendPartitions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAppendPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAppendPartitions.java index cfec569..b67f33d 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAppendPartitions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAppendPartitions.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.lang.StringUtils; @@ -44,7 +43,6 @@ import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -59,12 +57,7 @@ import com.google.common.collect.Lists; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestAppendPartitions { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestAppendPartitions extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -74,28 +67,8 @@ public class TestAppendPartitions { private static Table tableNoPartColumns; private static Table tableView; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestAppendPartitions(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestAppendPartitions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for (AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java index c1c1c61..8f97b19 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java @@ -40,65 +40,29 @@ import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * Test class for IMetaStoreClient API. Testing the Database related functions. */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestDatabases { - private static final Logger LOG = LoggerFactory.getLogger(TestDatabases.class); - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestDatabases extends MetaStoreClientTest { private static final String DEFAULT_DATABASE = "default"; private final AbstractMetaStoreService metaStore; private IMetaStoreClient client; private Database[] testDatabases = new Database[4]; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestDatabases(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestDatabases(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - try { - metaStoreService.stop(); - } catch(Exception e) { - // Catch the exceptions, so every other metastore could be stopped as well - // Log it, so at least there is a slight possibility we find out about this :) - LOG.error("Error stopping MetaStoreService", e); - } - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDropPartitions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDropPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDropPartitions.java index e550bca..4d94ebf 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDropPartitions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDropPartitions.java @@ -21,8 +21,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.metastore.IMetaStoreClient; @@ -40,9 +38,9 @@ import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.conf.MetastoreConf; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -55,12 +53,7 @@ import com.google.common.collect.Lists; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestDropPartitions { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestDropPartitions extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -72,34 +65,18 @@ public class TestDropPartitions { private static final short MAX = -1; private static final Partition[] PARTITIONS = new Partition[3]; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestDropPartitions(String name, AbstractMetaStoreService metaStore) throws Exception { - this.metaStore = metaStore; + @BeforeClass + public static void startMetaStores() { Map<MetastoreConf.ConfVars, String> msConf = new HashMap<MetastoreConf.ConfVars, String>(); // Enable trash, so it can be tested Map<String, String> extraConf = new HashMap<String, String>(); extraConf.put("fs.trash.checkpoint.interval", "30"); // FS_TRASH_CHECKPOINT_INTERVAL_KEY extraConf.put("fs.trash.interval", "30"); // FS_TRASH_INTERVAL_KEY (hadoop-2) - - this.metaStore.start(msConf, extraConf); + startMetaStores(msConf, extraConf); } - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } + public TestDropPartitions(String name, AbstractMetaStoreService metaStore) { + this.metaStore = metaStore; } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestExchangePartitions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestExchangePartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestExchangePartitions.java index 3a06aec..3bd1f8d 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestExchangePartitions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestExchangePartitions.java @@ -22,8 +22,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.metastore.IMetaStoreClient; @@ -42,7 +40,6 @@ import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,12 +54,7 @@ import com.google.common.collect.Lists; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestExchangePartitions { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestExchangePartitions extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -77,29 +69,8 @@ public class TestExchangePartitions { private static Table destTable; private static Partition[] partitions; - - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestExchangePartitions(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestExchangePartitions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for (AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestFunctions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestFunctions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestFunctions.java index 1974399..d504f34 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestFunctions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestFunctions.java @@ -36,7 +36,6 @@ import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.TApplicationException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -45,19 +44,13 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * Test class for IMetaStoreClient API. Testing the Function related functions. */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestFunctions { - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestFunctions extends MetaStoreClientTest { private static final String DEFAULT_DATABASE = "default"; private static final String OTHER_DATABASE = "dummy"; private static final String TEST_FUNCTION_CLASS = @@ -66,28 +59,8 @@ public class TestFunctions { private IMetaStoreClient client; private Function[] testFunctions = new Function[4]; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestFunctions(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestFunctions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetListIndexes.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetListIndexes.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetListIndexes.java index 1db7adc..5d226a8 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetListIndexes.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetListIndexes.java @@ -18,8 +18,6 @@ package org.apache.hadoop.hive.metastore.client; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.TableType; @@ -35,7 +33,6 @@ import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.TException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -50,11 +47,7 @@ import com.google.common.collect.Lists; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestGetListIndexes { - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestGetListIndexes extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -71,28 +64,8 @@ public class TestGetListIndexes { private static final Index[] INDEXES = new Index[5]; private static final short MAX = -1; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestGetListIndexes(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestGetListIndexes(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for (AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java index 2c7f3fb..fe5060b 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetPartitions.java @@ -19,8 +19,6 @@ package org.apache.hadoop.hive.metastore.client; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; @@ -39,7 +37,6 @@ import org.apache.thrift.transport.TTransportException; import com.google.common.collect.Lists; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -56,41 +53,15 @@ import static org.junit.Assert.fail; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestGetPartitions { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestGetPartitions extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; private static final String DB_NAME = "testpartdb"; private static final String TABLE_NAME = "testparttable"; - - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestGetPartitions(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestGetPartitions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetTableMeta.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetTableMeta.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetTableMeta.java index 7ede38f..4b22a7b 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetTableMeta.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetTableMeta.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hive.metastore.client; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Set; @@ -39,7 +38,6 @@ import org.apache.thrift.TException; import com.google.common.collect.Lists; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -55,12 +53,7 @@ import static org.junit.Assert.assertTrue; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestGetTableMeta { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestGetTableMeta extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; @@ -69,29 +62,8 @@ public class TestGetTableMeta { private List<TableMeta> expectedMetas = null; - - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(toSet()); - return result; - } - - public TestGetTableMeta(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestGetTableMeta(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java index 93bcd19..f5e4b8e 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestListPartitions.java @@ -20,8 +20,6 @@ package org.apache.hadoop.hive.metastore.client; import java.util.ArrayList; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; @@ -47,7 +45,6 @@ import org.apache.thrift.transport.TTransportException; import com.google.common.collect.Lists; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -66,41 +63,15 @@ import static org.junit.Assert.fail; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestListPartitions { - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestListPartitions extends MetaStoreClientTest { private AbstractMetaStoreService metaStore; private IMetaStoreClient client; private static final String DB_NAME = "testpartdb"; private static final String TABLE_NAME = "testparttable"; - - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestListPartitions(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestListPartitions(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java index dbcc57e..61ac483 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java @@ -42,9 +42,9 @@ import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -54,8 +54,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; /** * Test class for IMetaStoreClient API. Testing the Table related functions for metadata @@ -63,11 +61,7 @@ import java.util.stream.Collectors; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestTablesCreateDropAlterTruncate { - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestTablesCreateDropAlterTruncate extends MetaStoreClientTest { private static final String DEFAULT_DATABASE = "default"; private static final String OTHER_DATABASE = "dummy"; private final AbstractMetaStoreService metaStore; @@ -76,34 +70,18 @@ public class TestTablesCreateDropAlterTruncate { private Table partitionedTable = null; private Table externalTable = null; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; + public TestTablesCreateDropAlterTruncate(String name, AbstractMetaStoreService metaStore) { + this.metaStore = metaStore; } - public TestTablesCreateDropAlterTruncate(String name, AbstractMetaStoreService metaStore) throws Exception { - this.metaStore = metaStore; + @BeforeClass + public static void startMetaStores() { Map<MetastoreConf.ConfVars, String> msConf = new HashMap<MetastoreConf.ConfVars, String>(); // Enable trash, so it can be tested Map<String, String> extraConf = new HashMap<String, String>(); extraConf.put("fs.trash.checkpoint.interval", "30"); // FS_TRASH_CHECKPOINT_INTERVAL_KEY extraConf.put("fs.trash.interval", "30"); // FS_TRASH_INTERVAL_KEY (hadoop-2) - - this.metaStore.start(msConf, extraConf); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } + startMetaStores(msConf, extraConf); } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java index 0af873b..a1716ce 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java @@ -25,14 +25,12 @@ import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.api.UnknownDBException; -import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants; import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder; import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -42,8 +40,6 @@ import org.junit.runners.Parameterized; import java.util.ArrayList; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * Test class for IMetaStoreClient API. Testing the Table related functions for metadata @@ -51,39 +47,15 @@ import java.util.stream.Collectors; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestTablesGetExists { - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestTablesGetExists extends MetaStoreClientTest { private static final String DEFAULT_DATABASE = "default"; private static final String OTHER_DATABASE = "dummy"; private final AbstractMetaStoreService metaStore; private IMetaStoreClient client; private Table[] testTables = new Table[7]; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestTablesGetExists(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestTablesGetExists(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before http://git-wip-us.apache.org/repos/asf/hive/blob/f9768af0/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesList.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesList.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesList.java index 15bd6c6..7e4a59f 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesList.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesList.java @@ -22,17 +22,13 @@ import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest; import org.apache.hadoop.hive.metastore.api.InvalidOperationException; import org.apache.hadoop.hive.metastore.api.MetaException; -import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.api.UnknownDBException; import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants; import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder; import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.transport.TTransportException; import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -40,10 +36,7 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.util.ArrayList; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; /** * Test class for IMetaStoreClient API. Testing the Table related functions for metadata @@ -51,39 +44,15 @@ import java.util.stream.Collectors; */ @RunWith(Parameterized.class) @Category(MetastoreCheckinTest.class) -public class TestTablesList { - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should remove our own copy - private static Set<AbstractMetaStoreService> metaStoreServices = null; +public class TestTablesList extends MetaStoreClientTest { private static final String DEFAULT_DATABASE = "default"; private static final String OTHER_DATABASE = "dummy"; private final AbstractMetaStoreService metaStore; private IMetaStoreClient client; private Table[] testTables = new Table[7]; - @Parameterized.Parameters(name = "{0}") - public static List<Object[]> getMetaStoreToTest() throws Exception { - List<Object[]> result = MetaStoreFactoryForTests.getMetaStores(); - metaStoreServices = result.stream() - .map(test -> (AbstractMetaStoreService)test[1]) - .collect(Collectors.toSet()); - return result; - } - - public TestTablesList(String name, AbstractMetaStoreService metaStore) throws Exception { + public TestTablesList(String name, AbstractMetaStoreService metaStore) { this.metaStore = metaStore; - this.metaStore.start(); - } - - // Needed until there is no junit release with @BeforeParam, @AfterParam (junit 4.13) - // https://github.com/junit-team/junit4/commit/1bf8438b65858565dbb64736bfe13aae9cfc1b5a - // Then we should move this to @AfterParam - @AfterClass - public static void stopMetaStores() throws Exception { - for(AbstractMetaStoreService metaStoreService : metaStoreServices) { - metaStoreService.stop(); - } } @Before