kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From granthe...@apache.org
Subject kudu git commit: [java] Use TEST_TMPDIR environment variable in MiniKuduCluster
Date Wed, 18 Jul 2018 16:26:38 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 296b05ef4 -> c2cecb005


[java] Use TEST_TMPDIR environment variable in MiniKuduCluster

In order to match the functionality of the C++
MiniCluster, this change repects the TEST_TMPDIR
environment variable when creating a temporary
cluster root directory in MiniKuduCluster.java.

Change-Id: I1e3a8bb4e91680a00a0d70f9ad9d29ac6802751c
Reviewed-on: http://gerrit.cloudera.org:8080/10978
Reviewed-by: Adar Dembo <adar@cloudera.com>
Tested-by: Grant Henke <granthenke@apache.org>


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

Branch: refs/heads/master
Commit: c2cecb005c97efc8067475b603171a68f6875ebe
Parents: 296b05e
Author: Grant Henke <granthenke@apache.org>
Authored: Wed Jul 18 09:23:29 2018 -0500
Committer: Grant Henke <granthenke@apache.org>
Committed: Wed Jul 18 16:26:28 2018 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/client/MiniKuduCluster.java   | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/c2cecb00/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
index f922d25..d0714b2 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.file.Files;
-import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -115,7 +115,7 @@ public class MiniKuduCluster implements AutoCloseable {
       // If a cluster root was not set, create a  unique temp directory to use.
       // The mini cluster will clean this directory up on exit.
       try {
-        File tempRoot = Files.createTempDirectory("mini-kudu-cluster").toFile();
+        File tempRoot = getTempDirectory("mini-kudu-cluster");
         this.clusterRoot = tempRoot.toString();
       } catch (IOException ex) {
         throw new RuntimeException("Could not create cluster root directory", ex);
@@ -125,6 +125,20 @@ public class MiniKuduCluster implements AutoCloseable {
     }
   }
 
+  // Match the C++ MiniCluster test functionality for overriding the tmp directory used.
+  // See MakeClusterRoot in src/kudu/tools/tool_action_test.cc.
+  // If the TEST_TMPDIR environment variable is defined that directory will be used
+  // instead of the default temp directory.
+  private File getTempDirectory(String prefix) throws IOException  {
+    String testTmpdir = System.getenv("TEST_TMPDIR");
+    if (testTmpdir != null) {
+      LOG.info("Using the temp directory defined by TEST_TMPDIR: " + testTmpdir);
+      return Files.createTempDirectory(Paths.get(testTmpdir), prefix).toFile();
+    } else {
+      return Files.createTempDirectory(prefix).toFile();
+    }
+  }
+
   /**
    * Sends a command to the control shell and receives its response.
    * <p>


Mime
View raw message