IMPALA-5966: Fix the result file location of PlannerTest The Plannertest result files should be written to $IMPALA_FE_TEST_LOGS_DIR/PlannerTest, but instead they are written to $IMPALA_FE_TEST_LOGS_DIR with "PlannerTest" as the prefix of their filenames. This patch fixes this bug and refactores surrounding code a little, replacing some Strings with Paths.
Change-Id: I20005bd0421e1bb9f3eedbb003c97d92a8faf110 Reviewed-on: http://gerrit.cloudera.org:8080/8113 Reviewed-by: Alex Behm <[email protected]> Tested-by: Impala Public Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/a6438540 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/a6438540 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/a6438540 Branch: refs/heads/master Commit: a6438540a221b5df85ac764652e65a3f699eea0b Parents: 77c0e32 Author: Tianyi Wang <[email protected]> Authored: Wed Sep 20 14:39:24 2017 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Thu Sep 21 21:31:23 2017 +0000 ---------------------------------------------------------------------- .../apache/impala/planner/PlannerTestBase.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/a6438540/fe/src/test/java/org/apache/impala/planner/PlannerTestBase.java ---------------------------------------------------------------------- diff --git a/fe/src/test/java/org/apache/impala/planner/PlannerTestBase.java b/fe/src/test/java/org/apache/impala/planner/PlannerTestBase.java index 6ab4b8b..ae6488d 100644 --- a/fe/src/test/java/org/apache/impala/planner/PlannerTestBase.java +++ b/fe/src/test/java/org/apache/impala/planner/PlannerTestBase.java @@ -22,6 +22,7 @@ import static org.junit.Assert.fail; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -86,8 +87,9 @@ import com.google.common.collect.Sets; public class PlannerTestBase extends FrontendTestBase { private final static Logger LOG = LoggerFactory.getLogger(PlannerTest.class); private final static boolean GENERATE_OUTPUT_FILE = true; - private final String testDir_ = "functional-planner/queries/PlannerTest"; - private static String outDir_; + private final java.nio.file.Path testDir_ = Paths.get("functional-planner", "queries", + "PlannerTest"); + private static java.nio.file.Path outDir_; private static KuduClient kuduClient_; // Map from plan ID (TPlanNodeId) to the plan node with that ID. @@ -110,11 +112,8 @@ public class PlannerTestBase extends FrontendTestBase { kuduClient_ = new KuduClient.KuduClientBuilder("127.0.0.1:7051").build(); } String logDir = System.getenv("IMPALA_FE_TEST_LOGS_DIR"); - if (logDir != null) { - outDir_ = logDir + "/PlannerTest"; - } else { - outDir_ = "/tmp/PlannerTest"; - } + if (logDir == null) logDir = "/tmp"; + outDir_ = Paths.get(logDir, "PlannerTest"); } @Before @@ -736,7 +735,7 @@ public class PlannerTestBase extends FrontendTestBase { private void runPlannerTestFile(String testFile, String dbName, TQueryOptions options, boolean ignoreExplainHeader) { - String fileName = testDir_ + "/" + testFile + ".test"; + String fileName = testDir_.resolve(testFile + ".test").toString(); TestFileParser queryFileParser = new TestFileParser(fileName); StringBuilder actualOutput = new StringBuilder(); @@ -758,9 +757,8 @@ public class PlannerTestBase extends FrontendTestBase { // Create the actual output file if (GENERATE_OUTPUT_FILE) { try { - File outDirFile = new File(outDir_); - outDirFile.mkdirs(); - FileWriter fw = new FileWriter(outDir_ + testFile + ".test"); + outDir_.toFile().mkdirs(); + FileWriter fw = new FileWriter(outDir_.resolve(testFile + ".test").toFile()); fw.write(actualOutput.toString()); fw.close(); } catch (IOException e) {
