Repository: hive Updated Branches: refs/heads/master 016afe0d6 -> bda64ee87
HIVE-15910 : Improvements in Hive Unit Test by using In-memory Derby DB (Sankar Hariappan via Thejas Nair, Wei Zheng) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/bda64ee8 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/bda64ee8 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/bda64ee8 Branch: refs/heads/master Commit: bda64ee87c74a06b3cf19b08c41d67f192f22018 Parents: 016afe0 Author: Sankar Hariappan <[email protected]> Authored: Mon Feb 20 22:51:29 2017 -0800 Committer: Thejas M Nair <[email protected]> Committed: Mon Feb 20 22:51:34 2017 -0800 ---------------------------------------------------------------------- data/conf/hive-site.xml | 2 +- .../hadoop/hive/ql/txn/compactor/CompactorTest.java | 11 +++++++---- .../apache/hadoop/hive/ql/txn/compactor/TestCleaner.java | 6 ++++++ .../hadoop/hive/ql/txn/compactor/TestInitiator.java | 5 +++++ .../apache/hadoop/hive/ql/txn/compactor/TestWorker.java | 6 ++++++ 5 files changed, 25 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/bda64ee8/data/conf/hive-site.xml ---------------------------------------------------------------------- diff --git a/data/conf/hive-site.xml b/data/conf/hive-site.xml index 7a69711..62364fe 100644 --- a/data/conf/hive-site.xml +++ b/data/conf/hive-site.xml @@ -70,7 +70,7 @@ <property> <name>javax.jdo.option.ConnectionURL</name> - <value>jdbc:derby:;databaseName=${test.tmp.dir}/junit_metastore_db;create=true</value> + <value>jdbc:derby:memory:${test.tmp.dir}/junit_metastore_db;create=true</value> </property> <property> http://git-wip-us.apache.org/repos/asf/hive/blob/bda64ee8/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java index 2d1ecb5..bbed591 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hive.ql.txn.compactor; +import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; @@ -66,6 +67,7 @@ import org.slf4j.LoggerFactory; import java.io.EOFException; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -96,10 +98,11 @@ public abstract class CompactorTest { TxnDbUtil.cleanDb(); ms = new HiveMetaStoreClient(conf); txnHandler = TxnUtils.getTxnStore(conf); - tmpdir = new File(System.getProperty("java.io.tmpdir") + - System.getProperty("file.separator") + "compactor_test_tables"); - tmpdir.mkdir(); - tmpdir.deleteOnExit(); + tmpdir = new File (Files.createTempDirectory("compactor_test_table_").toString()); + } + + protected void compactorTestCleanup() throws IOException { + FileUtils.deleteDirectory(tmpdir); } protected void startInitiator() throws Exception { http://git-wip-us.apache.org/repos/asf/hive/blob/bda64ee8/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java index 44dd99b..0acf71b 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCleaner.java @@ -37,6 +37,7 @@ import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.api.UnlockRequest; import org.apache.hadoop.hive.metastore.txn.CompactionInfo; import org.apache.hadoop.hive.metastore.txn.TxnStore; +import org.junit.After; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; @@ -517,4 +518,9 @@ public class TestCleaner extends CompactorTest { boolean useHive130DeltaDirName() { return false; } + + @After + public void tearDown() throws Exception { + compactorTestCleanup(); + } } http://git-wip-us.apache.org/repos/asf/hive/blob/bda64ee8/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestInitiator.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestInitiator.java b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestInitiator.java index a11fe86..f75a1be 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestInitiator.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestInitiator.java @@ -35,6 +35,7 @@ import org.apache.hadoop.hive.metastore.api.ShowCompactResponse; import org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.txn.TxnStore; +import org.junit.After; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; @@ -752,4 +753,8 @@ public class TestInitiator extends CompactorTest { return false; } + @After + public void tearDown() throws Exception { + compactorTestCleanup(); + } } http://git-wip-us.apache.org/repos/asf/hive/blob/bda64ee8/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestWorker.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestWorker.java b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestWorker.java index e85f49c..efd6ed8 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestWorker.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestWorker.java @@ -33,6 +33,7 @@ import org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.txn.TxnStore; import org.apache.hadoop.hive.ql.io.AcidUtils; +import org.junit.After; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; @@ -977,4 +978,9 @@ public class TestWorker extends CompactorTest { Assert.assertEquals(1, compacts.size()); Assert.assertTrue(TxnStore.SUCCEEDED_RESPONSE.equals(rsp.getCompacts().get(0).getState())); } + + @After + public void tearDown() throws Exception { + compactorTestCleanup(); + } }
