Skip to content

Commit

Permalink
HIVE-15910 : Improvements in Hive Unit Test by using In-memory Derby …
Browse files Browse the repository at this point in the history
…DB (Sankar Hariappan via Thejas Nair, Wei Zheng)
  • Loading branch information
sankarh authored and Thejas M Nair committed Feb 21, 2017
1 parent 016afe0 commit bda64ee
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion data/conf/hive-site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -66,6 +67,7 @@
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;
Expand Down Expand Up @@ -96,10 +98,11 @@ protected CompactorTest() throws Exception {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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;
Expand Down Expand Up @@ -517,4 +518,9 @@ public void droppedPartition() throws Exception {
boolean useHive130DeltaDirName() {
return false;
}

@After
public void tearDown() throws Exception {
compactorTestCleanup();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -752,4 +753,8 @@ boolean useHive130DeltaDirName() {
return false;
}

@After
public void tearDown() throws Exception {
compactorTestCleanup();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -977,4 +978,9 @@ public void droppedPartition() throws Exception {
Assert.assertEquals(1, compacts.size());
Assert.assertTrue(TxnStore.SUCCEEDED_RESPONSE.equals(rsp.getCompacts().get(0).getState()));
}

@After
public void tearDown() throws Exception {
compactorTestCleanup();
}
}

0 comments on commit bda64ee

Please sign in to comment.