Skip to content

Commit

Permalink
Route GetTestDirectory to FileSystem in CompositeEnvWrappers (faceboo…
Browse files Browse the repository at this point in the history
…k#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: facebook#6896

Reviewed By: cheng-chang

Differential Revision: D21868984

Pulled By: ajkr

fbshipit-source-id: e79bfef758d06dacef727c54b96abe62e78726fd
  • Loading branch information
yhr authored and facebook-github-bot committed Jun 3, 2020
1 parent f005dac commit 0f85d16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
4 changes: 3 additions & 1 deletion env/composite_env_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
14 changes: 0 additions & 14 deletions env/env_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ThreadStatus>* thread_list) override {
assert(thread_status_updater_);
return thread_status_updater_->GetThreadList(thread_list);
Expand Down

0 comments on commit 0f85d16

Please sign in to comment.