diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java index 4ceee8c..b8cf94f 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.hadoop.hive.UtilsForTest; import org.apache.hadoop.hive.cli.CliSessionState; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; @@ -37,8 +38,8 @@ import org.apache.hadoop.hive.ql.Driver; import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.hive.shims.ShimLoader; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import com.google.common.collect.Lists; @@ -157,23 +158,25 @@ public Index filterIndex(Index index) throws NoSuchObjectException { private static final String TAB1 = "tab1"; private static final String TAB2 = "tab2"; private static final String INDEX1 = "idx1"; - private HiveConf hiveConf; - private HiveMetaStoreClient msc; - private Driver driver; + private static HiveConf hiveConf; + private static HiveMetaStoreClient msc; + private static Driver driver; - @Before - public void setUp() throws Exception { + @BeforeClass + public static void setUp() throws Exception { DummyMetaStoreFilterHookImpl.blockResults = false; - int port = MetaStoreUtils.findFreePort(); - MetaStoreUtils.startMetaStore(port, ShimLoader.getHadoopThriftAuthBridge()); - hiveConf = new HiveConf(this.getClass()); - hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + port); + hiveConf = new HiveConf(TestFilterHooks.class); hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3); hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, ""); hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, ""); hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false"); hiveConf.setVar(ConfVars.METASTORE_FILTER_HOOK, DummyMetaStoreFilterHookImpl.class.getName()); + UtilsForTest.setNewDerbyDbLocation(hiveConf, TestFilterHooks.class.getSimpleName()); + int port = MetaStoreUtils.findFreePort(); + hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + port); + MetaStoreUtils.startMetaStore(port, ShimLoader.getHadoopThriftAuthBridge(), hiveConf); + SessionState.start(new CliSessionState(hiveConf)); msc = new HiveMetaStoreClient(hiveConf, null); driver = new Driver(hiveConf); @@ -190,8 +193,8 @@ public void setUp() throws Exception { driver.run("CREATE INDEX " + INDEX1 + " on table " + TAB1 + "(id) AS 'COMPACT' WITH DEFERRED REBUILD"); } - @After - public void tearDown() throws Exception { + @AfterClass + public static void tearDown() throws Exception { DummyMetaStoreFilterHookImpl.blockResults = false; driver.run("drop database if exists " + DBNAME1 + " cascade"); driver.run("drop database if exists " + DBNAME2 + " cascade");