IMPALA-3516: Avoid writing to /tmp in testing Currently some parts of the tests write to /tmp: 1. PlannerTest result files are written to /tmp/PlannerTest 2. FE tests load libfesupport, which writes logs to /tmp 3. Updated results in EE tests (run-tests.py --update_results) is written to /tmp This patch changes them into writing to $IMPALA_HOME/logs. Specifically: 1. PlannerTest result files are written to $IMPALA_FE_TEST_LOGS_DIR/PlannerTest 2. libfesupport logs are written to $IMPALA_FE_TEST_LOGS_DIR 3. Updated EE test results are written to $IMPALA_EE_TEST_LOGS_DIR
Change-Id: I9e503eb7d333c1b89dc8aea87cf30504838c44f9 Reviewed-on: http://gerrit.cloudera.org:8080/8047 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/34d63e9d Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/34d63e9d Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/34d63e9d Branch: refs/heads/master Commit: 34d63e9dea9765c48ae2040bd25a718d39fc6314 Parents: d7e41a3 Author: Tianyi Wang <[email protected]> Authored: Mon Sep 11 15:34:49 2017 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Wed Sep 13 07:36:04 2017 +0000 ---------------------------------------------------------------------- be/src/service/fe-support.cc | 2 ++ .../test/java/org/apache/impala/planner/PlannerTestBase.java | 8 +++++++- tests/common/impala_test_suite.py | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/34d63e9d/be/src/service/fe-support.cc ---------------------------------------------------------------------- diff --git a/be/src/service/fe-support.cc b/be/src/service/fe-support.cc index 2c38b30..54b78a5 100644 --- a/be/src/service/fe-support.cc +++ b/be/src/service/fe-support.cc @@ -65,6 +65,8 @@ JNIEXPORT void JNICALL Java_org_apache_impala_service_FeSupport_NativeFeTestInit( JNIEnv* env, jclass caller_class) { DCHECK(ExecEnv::GetInstance() == NULL) << "This should only be called once from the FE"; + char* env_logs_dir_str = std::getenv("IMPALA_FE_TEST_LOGS_DIR"); + if (env_logs_dir_str != nullptr) FLAGS_log_dir = env_logs_dir_str; char* name = const_cast<char*>("FeSupport"); // Init the JVM to load the classes in JniUtil that are needed for returning // exceptions to the FE. http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/34d63e9d/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 6cd4e7a..6ab4b8b 100644 --- a/fe/src/test/java/org/apache/impala/planner/PlannerTestBase.java +++ b/fe/src/test/java/org/apache/impala/planner/PlannerTestBase.java @@ -87,7 +87,7 @@ 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 final String outDir_ = "/tmp/PlannerTest/"; + private static String outDir_; private static KuduClient kuduClient_; // Map from plan ID (TPlanNodeId) to the plan node with that ID. @@ -109,6 +109,12 @@ public class PlannerTestBase extends FrontendTestBase { if (RuntimeEnv.INSTANCE.isKuduSupported()) { 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"; + } } @Before http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/34d63e9d/tests/common/impala_test_suite.py ---------------------------------------------------------------------- diff --git a/tests/common/impala_test_suite.py b/tests/common/impala_test_suite.py index 1b7d043..b0857e9 100644 --- a/tests/common/impala_test_suite.py +++ b/tests/common/impala_test_suite.py @@ -97,6 +97,7 @@ WORKLOAD_DIR = os.environ['IMPALA_WORKLOAD_DIR'] HDFS_CONF = HdfsConfig(pytest.config.option.minicluster_xml_conf) TARGET_FILESYSTEM = os.getenv("TARGET_FILESYSTEM") or "hdfs" IMPALA_HOME = os.getenv("IMPALA_HOME") +EE_TEST_LOGS_DIR = os.getenv("IMPALA_EE_TEST_LOGS_DIR") # Match any SET statement. Assume that query options' names # only contain alphabets and underscores. SET_PATTERN = re.compile(r'\s*set\s*([a-zA-Z_]+)=*', re.I) @@ -440,7 +441,8 @@ class ImpalaTestSuite(BaseTestSuite): vector.get_value('table_format').file_format, pytest.config.option.update_results, result_section='DML_RESULTS') if pytest.config.option.update_results: - output_file = os.path.join('/tmp', test_file_name.replace('/','_') + ".test") + output_file = os.path.join(EE_TEST_LOGS_DIR, + test_file_name.replace('/','_') + ".test") write_test_file(output_file, sections, encoding=encoding) def execute_test_case_setup(self, setup_section, table_format):
