Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> [3/5] git commit: Update Hive test data generator so that it won't fail on subsequent runs.


Copy link to this message
-
[3/5] git commit: Update Hive test data generator so that it won't fail on subsequent runs.
Update Hive test data generator so that it won't fail on subsequent runs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/17ea5432
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/17ea5432
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/17ea5432

Branch: refs/heads/master
Commit: 17ea5432c35ba8dc6858b940fbe349955ecb74c6
Parents: 822bd9c
Author: Jacques Nadeau <[EMAIL PROTECTED]>
Authored: Tue Mar 11 08:43:00 2014 -0700
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Tue Mar 11 08:43:00 2014 -0700

 .../exec/store/hive/HiveTestDataGenerator.java  | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/17ea5432/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
index 7155a52..87b14ed 100644
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/hive/HiveTestDataGenerator.java
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.CommandNeedRetryException;
 import org.apache.hadoop.hive.ql.Driver;
@@ -33,18 +34,33 @@ public class HiveTestDataGenerator {
 
   static int RETRIES = 5;
   private Driver hiveDriver = null;
-
+  private static final String DB_DIR = "/tmp/drill_hive_db";
+  private static final String WH_DIR = "/tmp/drill_hive_wh";
+  
   public static void main(String[] args) throws Exception {
     HiveTestDataGenerator htd = new HiveTestDataGenerator();
     htd.generateTestData();
   }
 
+  private void cleanDir(String dir) throws IOException{
+    File f = new File(dir);
+    if(f.exists()){
+      FileUtils.cleanDirectory(f);
+      FileUtils.forceDelete(f);
+    }
+  }
+  
   public void generateTestData() throws Exception {
+    
+    // remove data from previous runs.
+    cleanDir(DB_DIR);
+    cleanDir(WH_DIR);
+    
     HiveConf conf = new HiveConf();
 
-    conf.set("javax.jdo.option.ConnectionURL", "jdbc:derby:;databaseName=/tmp/drill_hive_db;create=true");
+    conf.set("javax.jdo.option.ConnectionURL", String.format("jdbc:derby:;databaseName=%s;create=true", DB_DIR));
     conf.set("fs.default.name", "file:///");
-    conf.set("hive.metastore.warehouse.dir", "/tmp/drill_hive_wh");
+    conf.set("hive.metastore.warehouse.dir", WH_DIR);
 
     String tableName = "kv";