Repository: kudu Updated Branches: refs/heads/master fbf6062ca -> fa2b49548
Fix tests leaving behind diagnostics logs Prior to this patch, if tests are run with TEST_TMPDIR set, tests which use an internal minicluster could leave behind a diagnostics log file. The issue was the following: - GLog has some code which defaults FLAGS_log_dir to the the $TEST_TMPDIR environment variable. - Since we enabled the diagnosics log by default, this meant that minicluster servers would start logging into $TEST_TMPDIR directly - Our test harness only takes care of cleaning up the test-case-specific directory rather than the top-level $TEST_TMPDIR The fix here is to make our own test harness override FLAGS_log_dir to point to the test-specific directory. Tested by setting TEST_TMPDIR and running tablet_server-test. Before the patch, it left some files behind. With the patch, it did not. I couldn't write an easy automated test since the initialization of FLAGS_log_dir happens during glog's static constructors. Change-Id: Ic68826f652c7aefce1314d9e3481b11666f2699f Reviewed-on: http://gerrit.cloudera.org:8080/9592 Reviewed-by: Adar Dembo <a...@cloudera.com> Tested-by: Todd Lipcon <t...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/06704ec2 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/06704ec2 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/06704ec2 Branch: refs/heads/master Commit: 06704ec20f7adde0369f4ccca45f32976e0abe86 Parents: fbf6062 Author: Todd Lipcon <t...@apache.org> Authored: Mon Mar 12 15:46:06 2018 -0700 Committer: Todd Lipcon <t...@apache.org> Committed: Mon Mar 12 23:28:13 2018 +0000 ---------------------------------------------------------------------- src/kudu/master/master-test.cc | 7 ++++++- src/kudu/util/test_util.cc | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/06704ec2/src/kudu/master/master-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/master/master-test.cc b/src/kudu/master/master-test.cc index 4a8938a..bc5a0d1 100644 --- a/src/kudu/master/master-test.cc +++ b/src/kudu/master/master-test.cc @@ -73,6 +73,7 @@ #include "kudu/util/monotime.h" #include "kudu/util/net/net_util.h" #include "kudu/util/net/sockaddr.h" +#include "kudu/util/path_util.h" #include "kudu/util/pb_util.h" #include "kudu/util/random.h" #include "kudu/util/status.h" @@ -803,7 +804,11 @@ TEST_F(MasterTest, TestDumpStacksOnRpcQueueOverflow) { mini_master_->mutable_options()->rpc_opts.num_service_threads = 1; mini_master_->mutable_options()->rpc_opts.service_queue_length = 1; FLAGS_master_inject_latency_on_tablet_lookups_ms = 1000; - FLAGS_log_dir = GetTestDataDirectory(); + // Use a new log directory so that the tserver and master don't share the + // same one. This allows us to isolate the diagnostics log from the master. + FLAGS_log_dir = JoinPathSegments(GetTestDataDirectory(), "master-logs"); + Status s = env_->CreateDir(FLAGS_log_dir); + ASSERT_TRUE(s.ok() || s.IsAlreadyPresent()) << s.ToString(); mini_master_->Shutdown(); ASSERT_OK(mini_master_->Restart()); ASSERT_OK(mini_master_->master()-> http://git-wip-us.apache.org/repos/asf/kudu/blob/06704ec2/src/kudu/util/test_util.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/test_util.cc b/src/kudu/util/test_util.cc index c5acbbb..b9f919a 100644 --- a/src/kudu/util/test_util.cc +++ b/src/kudu/util/test_util.cc @@ -101,6 +101,10 @@ KuduTest::KuduTest() // only apply to certain tests. google::SetCommandLineOptionWithMode(e.first, e.second, google::SET_FLAGS_DEFAULT); } + // If the TEST_TMPDIR variable has been set, then glog will automatically use that + // as its default log directory. We would prefer that the default log directory + // instead be the test-case-specific subdirectory. + FLAGS_log_dir = GetTestDataDirectory(); } KuduTest::~KuduTest() {