From 0f85d163e60739597ff8f08fedc397514a7365dc Mon Sep 17 00:00:00 2001 From: Hans Holmberg Date: Wed, 3 Jun 2020 14:55:43 -0700 Subject: [PATCH] Route GetTestDirectory to FileSystem in CompositeEnvWrappers (#6896) Summary: GetTestDirectory implies a file system operation (it creates the default test directory if missing), so it should be routed to the FileSystem rather than the Env. Also remove the GetTestDirectory implementation in the PosixEnv, since it overrides GetTestDirectory in CompositeEnv making it impossible to override with a custom FileSystem. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6896 Reviewed By: cheng-chang Differential Revision: D21868984 Pulled By: ajkr fbshipit-source-id: e79bfef758d06dacef727c54b96abe62e78726fd --- env/composite_env_wrapper.h | 4 +++- env/env_posix.cc | 14 -------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/env/composite_env_wrapper.h b/env/composite_env_wrapper.h index 0c3f73977..6e4608b73 100644 --- a/env/composite_env_wrapper.h +++ b/env/composite_env_wrapper.h @@ -523,7 +523,9 @@ class CompositeEnvWrapper : public Env { return env_target_->GetThreadPoolQueueLen(pri); } Status GetTestDirectory(std::string* path) override { - return env_target_->GetTestDirectory(path); + IOOptions io_opts; + IODebugContext dbg; + return file_system_->GetTestDirectory(io_opts, path, &dbg); } uint64_t NowMicros() override { return env_target_->NowMicros(); } uint64_t NowNanos() override { return env_target_->NowNanos(); } diff --git a/env/env_posix.cc b/env/env_posix.cc index d89926386..38dc8bdee 100644 --- a/env/env_posix.cc +++ b/env/env_posix.cc @@ -224,20 +224,6 @@ class PosixEnv : public CompositeEnvWrapper { unsigned int GetThreadPoolQueueLen(Priority pri = LOW) const override; - Status GetTestDirectory(std::string* result) override { - const char* env = getenv("TEST_TMPDIR"); - if (env && env[0] != '\0') { - *result = env; - } else { - char buf[100]; - snprintf(buf, sizeof(buf), "/tmp/rocksdbtest-%d", int(geteuid())); - *result = buf; - } - // Directory may already exist - CreateDir(*result); - return Status::OK(); - } - Status GetThreadList(std::vector* thread_list) override { assert(thread_status_updater_); return thread_status_updater_->GetThreadList(thread_list);