PHOENIX-2418 Write Pherf results to temp directory

Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/78086974
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/78086974
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/78086974

Branch: refs/heads/txn
Commit: 7808697438b7cd815755ccebc8834968c0e54684
Parents: 5a18fa1
Author: Mujtaba <[email protected]>
Authored: Mon Nov 16 17:08:07 2015 -0800
Committer: Mujtaba <[email protected]>
Committed: Mon Nov 16 17:08:07 2015 -0800

----------------------------------------------------------------------
 phoenix-pherf/pom.xml                               |  4 ++++
 .../org/apache/phoenix/pherf/ResultBaseTestIT.java  |  9 ++++++---
 .../org/apache/phoenix/pherf/result/ResultUtil.java | 12 ++++++++++++
 .../org/apache/phoenix/pherf/ResultBaseTest.java    | 16 +++++++++-------
 4 files changed, 31 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/78086974/phoenix-pherf/pom.xml
----------------------------------------------------------------------
diff --git a/phoenix-pherf/pom.xml b/phoenix-pherf/pom.xml
index e3d375c..fecf2f5 100644
--- a/phoenix-pherf/pom.xml
+++ b/phoenix-pherf/pom.xml
@@ -146,6 +146,10 @@
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-surefire-plugin</artifactId>
+                                       <configuration>
+                                               
<workingDirectory>${java.io.tmpdir}</workingDirectory>
+                                               <forkCount>1</forkCount>
+                                       </configuration>
                        </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>

http://git-wip-us.apache.org/repos/asf/phoenix/blob/78086974/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java 
b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
index 1841d71..16d2d20 100644
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
+++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
@@ -23,6 +23,7 @@ import org.apache.phoenix.pherf.configuration.XMLConfigParser;
 import org.apache.phoenix.pherf.result.ResultUtil;
 import org.apache.phoenix.pherf.schema.SchemaReader;
 import org.apache.phoenix.pherf.util.PhoenixUtil;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
 import java.nio.file.Path;
@@ -45,12 +46,14 @@ public class ResultBaseTestIT extends 
BaseHBaseManagedTimeIT {
         PherfConstants constants = PherfConstants.create();
         properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES, 
false);
         String dir = properties.getProperty("pherf.default.results.dir");
-        String targetDir = "target/" + dir;
-        properties.setProperty("pherf.default.results.dir", targetDir);
-        resultUtil.ensureBaseDirExists(targetDir);
+        resultUtil.ensureBaseDirExists(dir);
 
         util.setZookeeper("localhost");
         reader = new SchemaReader(util, matcherSchema);
         parser = new XMLConfigParser(matcherScenario);
     }
+    
+    @AfterClass public static void tearDown() throws Exception {
+       
resultUtil.deleteDir(properties.getProperty("pherf.default.results.dir"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/78086974/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java
index d16a2f9..92eb80a 100644
--- 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java
+++ 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java
@@ -18,6 +18,7 @@
 
 package org.apache.phoenix.pherf.result;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.phoenix.pherf.PherfConstants;
 import org.apache.phoenix.pherf.result.file.ResultFileDetails;
 import org.apache.phoenix.pherf.result.impl.CSVFileResultHandler;
@@ -148,6 +149,17 @@ public class ResultUtil {
             baseDir.mkdir();
         }
     }
+    
+    /**
+     * Utility method to delete directory
+     * @throws IOException 
+     */
+    public void deleteDir(String directory) throws IOException {
+        File baseDir = new File(directory);
+        if (baseDir.exists()) {
+            FileUtils.deleteDirectory(baseDir);
+        }
+    }
 
     public String getSuffix() {
         if (null == FILE_SUFFIX) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/78086974/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java 
b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java
index 1497e77..5f80063 100644
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java
@@ -19,13 +19,15 @@
 package org.apache.phoenix.pherf;
 
 import org.apache.phoenix.pherf.result.ResultUtil;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
 import java.util.Properties;
 
 public class ResultBaseTest {
-    protected static PherfConstants constants;
+    private static PherfConstants constants;
     private static boolean isSetUpDone = false;
+    private static Properties properties;
 
     @BeforeClass
     public static void setUp() throws Exception {
@@ -33,13 +35,13 @@ public class ResultBaseTest {
             return;
         }
 
-        ResultUtil util = new ResultUtil();
         constants = PherfConstants.create();
-        Properties properties = 
constants.getProperties(PherfConstants.PHERF_PROPERTIES, false);
-        String dir = properties.getProperty("pherf.default.results.dir");
-        String targetDir = "target/" + dir;
-        properties.setProperty("pherf.default.results.dir", targetDir);
-        util.ensureBaseDirExists(targetDir);
+        properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES, 
false);
+        new 
ResultUtil().ensureBaseDirExists(properties.getProperty("pherf.default.results.dir"));
         isSetUpDone = true;
     }
+    
+    @AfterClass public static void tearDown() throws Exception {
+       new 
ResultUtil().deleteDir(properties.getProperty("pherf.default.results.dir"));
+    }
 }

Reply via email to