Make provision for db_stress to work with a pre-existing dir

Summary: The crash_test depends on db_stress to work with pre-existing dir

Test Plan: make db_stress; Run db_stress with 'destroy_db_initially=0'

Reviewers: vamsi, dhruba

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D10041
main
Mayank Agarwal 12 years ago
parent 26f68d3939
commit 9b3134f5ca
  1. 8
      tools/db_stress.cc

@ -62,6 +62,9 @@ static bool FLAGS_verify_before_write = false;
// Print histogram of operation timings // Print histogram of operation timings
static bool FLAGS_histogram = false; static bool FLAGS_histogram = false;
// Destroys the database dir before start if this is true
static bool FLAGS_destroy_db_initially = true;
static bool FLAGS_verbose = false; static bool FLAGS_verbose = false;
// Number of bytes to buffer in memtable before compacting // Number of bytes to buffer in memtable before compacting
@ -472,6 +475,7 @@ class StressTest {
: nullptr), : nullptr),
db_(nullptr), db_(nullptr),
num_times_reopened_(0) { num_times_reopened_(0) {
if (FLAGS_destroy_db_initially) {
std::vector<std::string> files; std::vector<std::string> files;
FLAGS_env->GetChildren(FLAGS_db, &files); FLAGS_env->GetChildren(FLAGS_db, &files);
for (unsigned int i = 0; i < files.size(); i++) { for (unsigned int i = 0; i < files.size(); i++) {
@ -481,6 +485,7 @@ class StressTest {
} }
DestroyDB(FLAGS_db, Options()); DestroyDB(FLAGS_db, Options());
} }
}
~StressTest() { ~StressTest() {
delete db_; delete db_;
@ -1001,6 +1006,9 @@ int main(int argc, char** argv) {
} else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 && } else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 &&
(n == 0 || n == 1)) { (n == 0 || n == 1)) {
FLAGS_histogram = n; FLAGS_histogram = n;
} else if (sscanf(argv[i], "--destroy_db_initially=%d%c", &n, &junk) == 1 &&
(n == 0 || n == 1)) {
FLAGS_destroy_db_initially = n;
} else if (sscanf(argv[i], "--verify_before_write=%d%c", &n, &junk) == 1 && } else if (sscanf(argv[i], "--verify_before_write=%d%c", &n, &junk) == 1 &&
(n == 0 || n == 1)) { (n == 0 || n == 1)) {
FLAGS_verify_before_write = n; FLAGS_verify_before_write = n;

Loading…
Cancel
Save