diff options
author | Dewal Gupta <dewal.gupta@10gen.com> | 2018-08-01 16:17:55 -0400 |
---|---|---|
committer | Dewal Gupta <dewal.gupta@10gen.com> | 2018-08-24 16:18:45 -0400 |
commit | d3656459d016d6a1be0788acfe3276734ab59210 (patch) | |
tree | 6223b5caad85b716151297d35845614816a48e5a /src/mongo/dbtests/framework_options.cpp | |
parent | fe2906300d0458e5421b576319b11274c56ea3c8 (diff) | |
download | mongo-d3656459d016d6a1be0788acfe3276734ab59210.tar.gz |
SERVER-13455 Add new configuration option for mongod to allow separate journal directory for WT
Diffstat (limited to 'src/mongo/dbtests/framework_options.cpp')
-rw-r--r-- | src/mongo/dbtests/framework_options.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/mongo/dbtests/framework_options.cpp b/src/mongo/dbtests/framework_options.cpp index d9929c5842c..ae25c038b49 100644 --- a/src/mongo/dbtests/framework_options.cpp +++ b/src/mongo/dbtests/framework_options.cpp @@ -50,8 +50,9 @@ namespace mongo { namespace { -// This specifies default dbpath for our testing framework +// This specifies default dbpath and journalPath for our testing framework const std::string default_test_dbpath = "/tmp/unittest"; +const std::string default_test_journalpath_subdir = "journal"; } // namespace @@ -74,6 +75,12 @@ Status addTestFrameworkOptions(moe::OptionSection* options) { "be overwritten if it already exists") .setDefault(moe::Value(default_test_dbpath)); + options->addOptionChaining("journalPath", + "journalPath", + moe::String, + "db journal path for this test run. NOTE: the contents of this " + "directory will be overwritten if it already exists"); + options->addOptionChaining("debug", "debug", moe::Switch, "run tests with verbose output"); options->addOptionChaining("list", "list,l", moe::Switch, "list available test suites"); @@ -137,6 +144,13 @@ Status storeTestFrameworkOptions(const moe::Environment& params, const std::vector<std::string>& args) { if (params.count("dbpath")) { frameworkGlobalParams.dbpathSpec = params["dbpath"].as<string>(); + auto path = boost::filesystem::path(frameworkGlobalParams.dbpathSpec); + path /= default_test_journalpath_subdir; + frameworkGlobalParams.journalPathSpec = path.string(); + } + + if (params.count("journalPath")) { + frameworkGlobalParams.journalPathSpec = params["journalPath"].as<string>(); } if (params.count("seed")) { @@ -157,6 +171,30 @@ Status storeTestFrameworkOptions(const moe::Environment& params, } boost::filesystem::path p(frameworkGlobalParams.dbpathSpec); + boost::filesystem::path journalPath(frameworkGlobalParams.journalPathSpec); + + /* remove the contents of the journal directory if it exists. */ + try { + if (boost::filesystem::exists(journalPath)) { + if (!boost::filesystem::is_directory(journalPath)) { + StringBuilder sb; + sb << "ERROR: path \"" << p.string() << "\" is not a directory"; + sb << getTestFrameworkHelp(args[0], moe::startupOptions); + return Status(ErrorCodes::BadValue, sb.str()); + } + boost::filesystem::directory_iterator end_iter; + for (boost::filesystem::directory_iterator dir_iter(journalPath); dir_iter != end_iter; + ++dir_iter) { + boost::filesystem::remove_all(*dir_iter); + } + } else { + boost::filesystem::create_directories(journalPath); + } + } catch (const boost::filesystem::filesystem_error& e) { + StringBuilder sb; + sb << "boost::filesystem threw exception: " << e.what(); + return Status(ErrorCodes::BadValue, sb.str()); + } /* remove the contents of the test directory if it exists. */ try { @@ -184,7 +222,11 @@ Status storeTestFrameworkOptions(const moe::Environment& params, DEV log() << "DEBUG build" << endl; string dbpathString = p.string(); + // For both Windows and Mac, wiredtiger requires forward slashes in the journal path. Using + // 'generic_string' forces that conversion. + string journalPathString = journalPath.generic_string(); storageGlobalParams.dbpath = dbpathString.c_str(); + storageGlobalParams.journalPath = journalPathString.c_str(); storageGlobalParams.engine = params["storage.engine"].as<string>(); |