kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/3] kudu git commit: test_util: prefer test_dir_ over GetTestDataDirectory()
Date Wed, 16 Nov 2016 02:00:35 GMT
Repository: kudu
Updated Branches:
  refs/heads/master e05a82f5f -> e836ac18d


test_util: prefer test_dir_ over GetTestDataDirectory()

The latter is more expensive to call. Originally I wanted to restrict it
entirely to KuduTest, but there are a couple places where we don't have a
KuduTest but need to call (e.g. mini cluster constructors).

Change-Id: Ife4dbbe6002b0dbd0a0699fc3a475c9d6f43bcf7
Reviewed-on: http://gerrit.cloudera.org:8080/5028
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <danburkert@apache.org>


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

Branch: refs/heads/master
Commit: 2cd07929ac773ca82f6a47e837f6ad0c4788fe75
Parents: e05a82f
Author: Adar Dembo <adar@cloudera.com>
Authored: Thu Nov 3 20:12:59 2016 -0700
Committer: Adar Dembo <adar@cloudera.com>
Committed: Wed Nov 16 01:59:56 2016 +0000

----------------------------------------------------------------------
 src/kudu/consensus/log_index-test.cc            |  2 +-
 src/kudu/fs/block_manager-stress-test.cc        |  2 +-
 src/kudu/fs/block_manager-test.cc               | 80 ++++++++++----------
 src/kudu/fs/block_manager_util-test.cc          |  4 +-
 .../integration-tests/disk_reservation-itest.cc |  7 +-
 src/kudu/rpc/rpc-test-base.h                    |  4 +-
 src/kudu/rpc/rpc_stub-test.cc                   |  2 +-
 src/kudu/tablet/deltafile-test.cc               |  2 +-
 src/kudu/util/env-test.cc                       |  4 +-
 src/kudu/util/env_util-test.cc                  |  5 +-
 src/kudu/util/test_util.cc                      |  1 -
 src/kudu/util/test_util.h                       |  5 +-
 12 files changed, 57 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/consensus/log_index-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_index-test.cc b/src/kudu/consensus/log_index-test.cc
index 022ddce..7bbafea 100644
--- a/src/kudu/consensus/log_index-test.cc
+++ b/src/kudu/consensus/log_index-test.cc
@@ -31,7 +31,7 @@ class LogIndexTest : public KuduTest {
  public:
   virtual void SetUp() OVERRIDE {
     KuduTest::SetUp();
-    index_ = new LogIndex(GetTestDataDirectory());
+    index_ = new LogIndex(test_dir_);
   }
 
  protected:

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/fs/block_manager-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-stress-test.cc b/src/kudu/fs/block_manager-stress-test.cc
index caf7710..f5c6353 100644
--- a/src/kudu/fs/block_manager-stress-test.cc
+++ b/src/kudu/fs/block_manager-stress-test.cc
@@ -109,7 +109,7 @@ class BlockManagerStressTest : public KuduTest {
   BlockManager* CreateBlockManager() {
     BlockManagerOptions opts;
     if (FLAGS_block_manager_paths.empty()) {
-      opts.root_paths.push_back(GetTestDataDirectory());
+      opts.root_paths.push_back(test_dir_);
     } else {
       opts.root_paths = strings::Split(FLAGS_block_manager_paths, ",",
                                        strings::SkipEmpty());

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/fs/block_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-test.cc b/src/kudu/fs/block_manager-test.cc
index 8d47534..62d4847 100644
--- a/src/kudu/fs/block_manager-test.cc
+++ b/src/kudu/fs/block_manager-test.cc
@@ -91,7 +91,7 @@ class BlockManagerTest : public KuduTest {
   BlockManagerTest() :
     bm_(CreateBlockManager(scoped_refptr<MetricEntity>(),
                            shared_ptr<MemTracker>(),
-                           { GetTestDataDirectory() })) {
+                           { test_dir_ })) {
   }
 
   virtual void SetUp() OVERRIDE {
@@ -245,10 +245,10 @@ template <>
 void BlockManagerTest<LogBlockManager>::RunLogMetricsTest() {
   MetricRegistry registry;
   scoped_refptr<MetricEntity> entity = METRIC_ENTITY_server.Instantiate(&registry,
"test");
-  ASSERT_OK(this->ReopenBlockManager(entity,
-                                     shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
-                                     false));
+  ASSERT_OK(ReopenBlockManager(entity,
+                               shared_ptr<MemTracker>(),
+                               { test_dir_ },
+                               false));
   ASSERT_NO_FATAL_FAILURE(CheckLogMetrics(entity, 0, 0, 0, 0));
 
   // Lower the max container size so that we can more easily test full
@@ -257,7 +257,7 @@ void BlockManagerTest<LogBlockManager>::RunLogMetricsTest() {
 
   // One block --> one container.
   gscoped_ptr<WritableBlock> writer;
-  ASSERT_OK(this->bm_->CreateBlock(&writer));
+  ASSERT_OK(bm_->CreateBlock(&writer));
   ASSERT_NO_FATAL_FAILURE(CheckLogMetrics(entity, 0, 0, 1, 0));
 
   // And when the block is closed, it becomes "under management".
@@ -272,7 +272,7 @@ void BlockManagerTest<LogBlockManager>::RunLogMetricsTest() {
     ScopedWritableBlockCloser closer;
     for (int i = 0; i < 10; i++) {
       gscoped_ptr<WritableBlock> b;
-      ASSERT_OK(this->bm_->CreateBlock(&b));
+      ASSERT_OK(bm_->CreateBlock(&b));
       if (saved_id.IsNull()) {
         saved_id = b->id();
       }
@@ -294,14 +294,14 @@ void BlockManagerTest<LogBlockManager>::RunLogMetricsTest() {
   // persistent information so they should be the same.
   MetricRegistry new_registry;
   scoped_refptr<MetricEntity> new_entity = METRIC_ENTITY_server.Instantiate(&new_registry,
"test");
-  ASSERT_OK(this->ReopenBlockManager(new_entity,
-                                     shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
-                                     false));
+  ASSERT_OK(ReopenBlockManager(new_entity,
+                               shared_ptr<MemTracker>(),
+                               { test_dir_ },
+                               false));
   ASSERT_NO_FATAL_FAILURE(CheckLogMetrics(new_entity, 10 * 1024, 11, 10, 10));
 
   // Delete a block. Its contents should no longer be under management.
-  ASSERT_OK(this->bm_->DeleteBlock(saved_id));
+  ASSERT_OK(bm_->DeleteBlock(saved_id));
   ASSERT_NO_FATAL_FAILURE(CheckLogMetrics(new_entity, 9 * 1024, 10, 10, 10));
 }
 
@@ -321,7 +321,7 @@ void BlockManagerTest<LogBlockManager>::RunLogContainerPreallocationTest()
{
   // Create a block with some test data. This should also trigger
   // preallocation of the container, provided it's supported by the kernel.
   gscoped_ptr<WritableBlock> written_block;
-  ASSERT_OK(this->bm_->CreateBlock(&written_block));
+  ASSERT_OK(bm_->CreateBlock(&written_block));
   ASSERT_OK(written_block->Append(kTestData));
   ASSERT_OK(written_block->Close());
 
@@ -331,32 +331,32 @@ void BlockManagerTest<LogBlockManager>::RunLogContainerPreallocationTest()
{
   string container_data_filename;
   NO_FATALS(GetOnlyContainerDataFile(&container_data_filename));
   uint64_t size;
-  ASSERT_OK(this->env_->GetFileSizeOnDisk(container_data_filename, &size));
+  ASSERT_OK(env_->GetFileSizeOnDisk(container_data_filename, &size));
   ASSERT_TRUE(size == kTestData.size() ||
               size == FLAGS_log_container_preallocate_bytes);
 
   // Upon writing a second block, we'd expect the container to either double in
   // size (without preallocation) or remain the same size (with preallocation).
-  ASSERT_OK(this->bm_->CreateBlock(&written_block));
+  ASSERT_OK(bm_->CreateBlock(&written_block));
   ASSERT_OK(written_block->Append(kTestData));
   ASSERT_OK(written_block->Close());
   NO_FATALS(GetOnlyContainerDataFile(&container_data_filename));
-  ASSERT_OK(this->env_->GetFileSizeOnDisk(container_data_filename, &size));
+  ASSERT_OK(env_->GetFileSizeOnDisk(container_data_filename, &size));
   ASSERT_TRUE(size == kTestData.size() * 2 ||
               size == FLAGS_log_container_preallocate_bytes);
 
 
   // Now reopen the block manager and create another block. The block manager
   // should be smart enough to reuse the previously preallocated amount.
-  ASSERT_OK(this->ReopenBlockManager(scoped_refptr<MetricEntity>(),
-                                     shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
-                                     false));
-  ASSERT_OK(this->bm_->CreateBlock(&written_block));
+  ASSERT_OK(ReopenBlockManager(scoped_refptr<MetricEntity>(),
+                               shared_ptr<MemTracker>(),
+                               { test_dir_ },
+                               false));
+  ASSERT_OK(bm_->CreateBlock(&written_block));
   ASSERT_OK(written_block->Append(kTestData));
   ASSERT_OK(written_block->Close());
   NO_FATALS(GetOnlyContainerDataFile(&container_data_filename));
-  ASSERT_OK(this->env_->GetFileSizeOnDisk(container_data_filename, &size));
+  ASSERT_OK(env_->GetFileSizeOnDisk(container_data_filename, &size));
   ASSERT_TRUE(size == kTestData.size() * 3 ||
               size == FLAGS_log_container_preallocate_bytes);
 }
@@ -364,16 +364,16 @@ void BlockManagerTest<LogBlockManager>::RunLogContainerPreallocationTest()
{
 template <>
 void BlockManagerTest<FileBlockManager>::RunMemTrackerTest() {
   shared_ptr<MemTracker> tracker = MemTracker::CreateTracker(-1, "test tracker");
-  ASSERT_OK(this->ReopenBlockManager(scoped_refptr<MetricEntity>(),
-                                     tracker,
-                                     { GetTestDataDirectory() },
-                                     false));
+  ASSERT_OK(ReopenBlockManager(scoped_refptr<MetricEntity>(),
+                               tracker,
+                               { test_dir_ },
+                               false));
 
   // The file block manager does not allocate memory for persistent data.
   int64_t initial_mem = tracker->consumption();
   ASSERT_EQ(initial_mem, 0);
   gscoped_ptr<WritableBlock> writer;
-  ASSERT_OK(this->bm_->CreateBlock(&writer));
+  ASSERT_OK(bm_->CreateBlock(&writer));
   ASSERT_OK(writer->Close());
   ASSERT_EQ(tracker->consumption(), initial_mem);
 }
@@ -381,10 +381,10 @@ void BlockManagerTest<FileBlockManager>::RunMemTrackerTest() {
 template <>
 void BlockManagerTest<LogBlockManager>::RunMemTrackerTest() {
   shared_ptr<MemTracker> tracker = MemTracker::CreateTracker(-1, "test tracker");
-  ASSERT_OK(this->ReopenBlockManager(scoped_refptr<MetricEntity>(),
-                                     tracker,
-                                     { GetTestDataDirectory() },
-                                     false));
+  ASSERT_OK(ReopenBlockManager(scoped_refptr<MetricEntity>(),
+                               tracker,
+                               { test_dir_ },
+                               false));
 
   // The initial consumption should be non-zero due to the block map.
   int64_t initial_mem = tracker->consumption();
@@ -392,7 +392,7 @@ void BlockManagerTest<LogBlockManager>::RunMemTrackerTest() {
 
   // Allocating a persistent block should increase the consumption.
   gscoped_ptr<WritableBlock> writer;
-  ASSERT_OK(this->bm_->CreateBlock(&writer));
+  ASSERT_OK(bm_->CreateBlock(&writer));
   ASSERT_OK(writer->Close());
   ASSERT_GT(tracker->consumption(), initial_mem);
 }
@@ -576,7 +576,7 @@ TYPED_TEST(BlockManagerTest, AbortTest) {
   scoped_refptr<MetricEntity> entity = METRIC_ENTITY_server.Instantiate(&registry,
"test");
   ASSERT_OK(this->ReopenBlockManager(entity,
                                      shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
+                                     { this->test_dir_ },
                                      false));
 
   gscoped_ptr<WritableBlock> written_block;
@@ -626,7 +626,7 @@ TYPED_TEST(BlockManagerTest, PersistenceTest) {
   gscoped_ptr<BlockManager> new_bm(this->CreateBlockManager(
       scoped_refptr<MetricEntity>(),
       MemTracker::CreateTracker(-1, "other tracker"),
-      { GetTestDataDirectory() }));
+      { this->test_dir_ }));
   ASSERT_OK(new_bm->Open());
 
   // Test that the state of all three blocks is properly reflected.
@@ -693,7 +693,7 @@ TYPED_TEST(BlockManagerTest, MetricsTest) {
   scoped_refptr<MetricEntity> entity = METRIC_ENTITY_server.Instantiate(&registry,
"test");
   ASSERT_OK(this->ReopenBlockManager(entity,
                                      shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
+                                     { this->test_dir_ },
                                      false));
   ASSERT_NO_FATAL_FAILURE(CheckMetrics(entity, 0, 0, 0, 0, 0, 0));
 
@@ -811,7 +811,7 @@ TEST_F(LogBlockManagerTest, TestReuseBlockIds) {
   // block IDs have been reused.
   ASSERT_OK(ReopenBlockManager(scoped_refptr<MetricEntity>(),
                                shared_ptr<MemTracker>(),
-                               { GetTestDataDirectory() },
+                               { this->test_dir_ },
                                false));
 }
 
@@ -875,7 +875,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
   // the metadata file will be restored back to its previous value.
   ASSERT_OK(this->ReopenBlockManager(scoped_refptr<MetricEntity>(),
                                      shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
+                                     { this->test_dir_ },
                                      false));
   ASSERT_EQ(4, bm_->CountBlocksForTests());
   ASSERT_OK(bm_->OpenBlock(last_block_id, &block));
@@ -922,7 +922,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
   // Reopen the truncated metadata file. We will not find all of our blocks.
   ASSERT_OK(this->ReopenBlockManager(scoped_refptr<MetricEntity>(),
                                      shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
+                                     { this->test_dir_ },
                                      false));
 
   // Because the last record was a partial record on disk, the system should
@@ -989,7 +989,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
   // This should look like a bad checksum, and it's not recoverable.
   s = this->ReopenBlockManager(scoped_refptr<MetricEntity>(),
                                shared_ptr<MemTracker>(),
-                               { GetTestDataDirectory() },
+                               { this->test_dir_ },
                                false);
   ASSERT_TRUE(s.IsCorruption());
   ASSERT_STR_CONTAINS(s.ToString(), "Incorrect checksum");
@@ -1003,7 +1003,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
 
   ASSERT_OK(this->ReopenBlockManager(scoped_refptr<MetricEntity>(),
                                      shared_ptr<MemTracker>(),
-                                     { GetTestDataDirectory() },
+                                     { this->test_dir_ },
                                      false));
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/fs/block_manager_util-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager_util-test.cc b/src/kudu/fs/block_manager_util-test.cc
index c194a6c..ee19638 100644
--- a/src/kudu/fs/block_manager_util-test.cc
+++ b/src/kudu/fs/block_manager_util-test.cc
@@ -38,7 +38,7 @@ using strings::Substitute;
 
 TEST_F(KuduTest, Lifecycle) {
   string kType = "asdf";
-  string kFileName = JoinPathSegments(GetTestDataDirectory(), "foo");
+  string kFileName = GetTestPath("foo");
   string kUuid = "a_uuid";
 
   // Test that the metadata file was created.
@@ -70,7 +70,7 @@ TEST_F(KuduTest, Lifecycle) {
 
 TEST_F(KuduTest, Locking) {
   string kType = "asdf";
-  string kFileName = JoinPathSegments(GetTestDataDirectory(), "foo");
+  string kFileName = GetTestPath("foo");
   string kUuid = "a_uuid";
 
   PathInstanceMetadataFile file(env_, kType, kFileName);

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/integration-tests/disk_reservation-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/disk_reservation-itest.cc b/src/kudu/integration-tests/disk_reservation-itest.cc
index a4357b0..ae81d8c 100644
--- a/src/kudu/integration-tests/disk_reservation-itest.cc
+++ b/src/kudu/integration-tests/disk_reservation-itest.cc
@@ -59,12 +59,11 @@ TEST_F(DiskReservationITest, TestFillMultipleDisks) {
   // Reserve one byte so that when we simulate 0 bytes free below, we'll start
   // failing requests.
   ts_flags.push_back("--fs_data_dirs_reserved_bytes=1");
-  ts_flags.push_back(Substitute("--fs_data_dirs=$0/a,$0/b",
-                                GetTestDataDirectory()));
+  ts_flags.push_back(Substitute("--fs_data_dirs=$0/a,$0/b", test_dir_));
   ts_flags.push_back(Substitute("--disk_reserved_override_prefix_1_path_for_testing=$0/a",
-                                GetTestDataDirectory()));
+                                test_dir_));
   ts_flags.push_back(Substitute("--disk_reserved_override_prefix_2_path_for_testing=$0/b",
-                                GetTestDataDirectory()));
+                                test_dir_));
 
   NO_FATALS(StartCluster(ts_flags, {}, 1));
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/rpc/rpc-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc-test-base.h b/src/kudu/rpc/rpc-test-base.h
index d747fda..1e2d4fc 100644
--- a/src/kudu/rpc/rpc-test-base.h
+++ b/src/kudu/rpc/rpc-test-base.h
@@ -415,8 +415,8 @@ class RpcTestBase : public KuduTest {
                                              int n_reactors = 1,
                                              bool enable_ssl = false) {
     if (enable_ssl) {
-      std::string server_cert_path = JoinPathSegments(GetTestDataDirectory(), "server-cert.pem");
-      std::string private_key_path = JoinPathSegments(GetTestDataDirectory(), "server-key.pem");
+      std::string server_cert_path = GetTestPath("server-cert.pem");
+      std::string private_key_path = GetTestPath("server-key.pem");
       CHECK_OK(CreateSSLServerCert(server_cert_path));
       CHECK_OK(CreateSSLPrivateKey(private_key_path));
       FLAGS_rpc_ssl_server_certificate = server_cert_path;

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/rpc/rpc_stub-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc_stub-test.cc b/src/kudu/rpc/rpc_stub-test.cc
index 67371cb..07d7397 100644
--- a/src/kudu/rpc/rpc_stub-test.cc
+++ b/src/kudu/rpc/rpc_stub-test.cc
@@ -327,7 +327,7 @@ TEST_F(RpcStubTest, TestRpcPanic) {
   } else {
     // Before forcing the panic, explicitly remove the test directory. This
     // should be safe; this test doesn't generate any data.
-    CHECK_OK(env_->DeleteRecursively(GetTestDataDirectory()));
+    CHECK_OK(env_->DeleteRecursively(test_dir_));
 
     // Make an RPC which causes the server to abort.
     CalculatorServiceProxy p(client_messenger_, server_addr_);

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/tablet/deltafile-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/deltafile-test.cc b/src/kudu/tablet/deltafile-test.cc
index 56df74d..f58754a 100644
--- a/src/kudu/tablet/deltafile-test.cc
+++ b/src/kudu/tablet/deltafile-test.cc
@@ -58,7 +58,7 @@ class TestDeltaFile : public KuduTest {
 
  public:
   void SetUp() OVERRIDE {
-    fs_manager_.reset(new FsManager(env_, GetTestDataDirectory() + "/fs"));
+    fs_manager_.reset(new FsManager(env_, GetTestPath("fs")));
     ASSERT_OK(fs_manager_->CreateInitialFileSystemLayout());
     ASSERT_OK(fs_manager_->Open());
   }

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/util/env-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/env-test.cc b/src/kudu/util/env-test.cc
index 5d11167..e132bca 100644
--- a/src/kudu/util/env-test.cc
+++ b/src/kudu/util/env-test.cc
@@ -473,7 +473,7 @@ TEST_F(TestEnv, TestGetExecutablePath) {
 
 TEST_F(TestEnv, TestOpenEmptyRandomAccessFile) {
   Env* env = Env::Default();
-  string test_file = JoinPathSegments(GetTestDataDirectory(), "test_file");
+  string test_file = GetTestPath("test_file");
   ASSERT_NO_FATAL_FAILURE(WriteTestFile(env, test_file, 0));
   gscoped_ptr<RandomAccessFile> readable_file;
   ASSERT_OK(env->NewRandomAccessFile(test_file, &readable_file));
@@ -701,7 +701,7 @@ TEST_F(TestEnv, TestCanonicalize) {
   for (const string& synonym : synonyms) {
     string result;
     ASSERT_OK(env_->Canonicalize(synonym, &result));
-    ASSERT_EQ(GetTestDataDirectory(), result);
+    ASSERT_EQ(test_dir_, result);
   }
 
   string dir = GetTestPath("some_dir");

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/util/env_util-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/env_util-test.cc b/src/kudu/util/env_util-test.cc
index 755aaaf..3676d64 100644
--- a/src/kudu/util/env_util-test.cc
+++ b/src/kudu/util/env_util-test.cc
@@ -36,18 +36,17 @@ class EnvUtilTest: public KuduTest {
 
 TEST_F(EnvUtilTest, TestDiskSpaceCheck) {
   Env* env = Env::Default();
-  const string kTestPath = GetTestDataDirectory();
 
   const int64_t kRequestedBytes = 0;
   int64_t reserved_bytes = 0;
-  ASSERT_OK(env_util::VerifySufficientDiskSpace(env, kTestPath, kRequestedBytes, reserved_bytes));
+  ASSERT_OK(env_util::VerifySufficientDiskSpace(env, test_dir_, kRequestedBytes, reserved_bytes));
 
   // Make it seem as if the disk is full and specify that we should have
   // reserved 200 bytes. Even asking for 0 bytes should return an error
   // indicating we are out of space.
   FLAGS_disk_reserved_bytes_free_for_testing = 0;
   reserved_bytes = 200;
-  Status s = env_util::VerifySufficientDiskSpace(env, kTestPath, kRequestedBytes, reserved_bytes);
+  Status s = env_util::VerifySufficientDiskSpace(env, test_dir_, kRequestedBytes, reserved_bytes);
   ASSERT_TRUE(s.IsIOError());
   ASSERT_EQ(ENOSPC, s.posix_code());
   ASSERT_STR_CONTAINS(s.ToString(), "Insufficient disk space");

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/util/test_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/test_util.cc b/src/kudu/util/test_util.cc
index 7a74a9f..3414797 100644
--- a/src/kudu/util/test_util.cc
+++ b/src/kudu/util/test_util.cc
@@ -85,7 +85,6 @@ void KuduTest::SetUp() {
 }
 
 string KuduTest::GetTestPath(const string& relative_path) {
-  CHECK(!test_dir_.empty()) << "Call SetUp() first";
   return JoinPathSegments(test_dir_, relative_path);
 }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/2cd07929/src/kudu/util/test_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/test_util.h b/src/kudu/util/test_util.h
index 238fa1d..bb48ee1 100644
--- a/src/kudu/util/test_util.h
+++ b/src/kudu/util/test_util.h
@@ -54,8 +54,6 @@ class KuduTest : public ::testing::Test {
 
   Env* env_;
   google::FlagSaver flag_saver_;  // Reset flags on every test.
-
- private:
   std::string test_dir_;
 };
 
@@ -83,7 +81,8 @@ int SeedRandom();
 // Return a per-test directory in which to store test data. Guaranteed to
 // return the same directory every time for a given unit test.
 //
-// May only be called from within a gtest unit test.
+// May only be called from within a gtest unit test. Prefer KuduTest::test_dir_
+// if a KuduTest instance is available.
 std::string GetTestDataDirectory();
 
 // Wait until 'f()' succeeds without adding any GTest 'fatal failures'.


Mime
View raw message