std::string dbname = vals["ep_dbname"];
- /* Nuke the database directory to simulate the commit failure */
- rmdb(dbname.c_str());
+ /* Nuke the database directory to simulate the commit failure.
+ * In case of failure to remove the directory, then retry atmost
+ * 10 times.
+ */
+ int retries = 0;
+ while (rmdb(dbname.c_str()) == FAIL && retries < 10) {
+ retries++;
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
checkeq(ENGINE_SUCCESS, store(h, h1, NULL, OPERATION_SET,"key", "somevalue",
NULL, 0, 0, 0), "store should have succeeded");
}
enum test_result rmdb(const char* path) {
- cb::io::rmrf(path);
+ try {
+ cb::io::rmrf(path);
+ } catch (std::system_error& e) {
+ throw e;
+ }
if (access(path, F_OK) != -1) {
std::cerr << "Failed to remove: " << path << " " << std::endl;
return FAIL;
std::string dbname = get_dbname(test->cfg);
/* Remove if the same DB directory already exists */
- rmdb(dbname.c_str());
+ try {
+ rmdb(dbname.c_str());
+ } catch (std::system_error& e) {
+ if (e.code() != std::error_code(ENOENT, std::system_category())) {
+ throw e;
+ }
+ }
mkdir(dbname.c_str(), 0777);
return SUCCESS;
}
// Nuke the database files we created
std::string dbname = get_dbname(test->cfg);
/* Remove only the db file this test created */
- rmdb(dbname.c_str());
+ try {
+ rmdb(dbname.c_str());
+ } catch (std::system_error& e) {
+ if (e.code() != std::error_code(ENOENT, std::system_category())) {
+ throw e;
+ }
+ }
}
// Array of testcases to return back to engine_testapp.
config << str_cfg << "dbname=" << dbpath.str();
}
- rmdb(dbpath.str().c_str());
+ try {
+ rmdb(dbpath.str().c_str());
+ } catch (std::system_error& e) {
+ if (e.code() != std::error_code(ENOENT, std::system_category())) {
+ throw e;
+ }
+ }
ENGINE_HANDLE_V1* handle = testHarness.create_bucket(true, config.str().c_str());
if (handle) {
buckets.push_back(BucketHolder((ENGINE_HANDLE*)handle, handle, dbpath.str()));
void EventuallyPersistentEngineTest::SetUp() {
// Paranoia - kill any existing files in case they are left over
// from a previous run.
- cb::io::rmrf(test_dbname);
+ try {
+ cb::io::rmrf(test_dbname);
+ } catch (std::system_error& e) {
+ if (e.code() != std::error_code(ENOENT, std::system_category())) {
+ throw e;
+ }
+ }
// Setup an engine with a single active vBucket.
EXPECT_EQ(ENGINE_SUCCESS,
void KVBucketTest::SetUp() {
// Paranoia - kill any existing files in case they are left over
// from a previous run.
- cb::io::rmrf(test_dbname);
+ try {
+ cb::io::rmrf(test_dbname);
+ } catch (std::system_error& e) {
+ if (e.code() != std::error_code(ENOENT, std::system_category())) {
+ throw e;
+ }
+ }
// Add dbname to config string.
std::string config = config_string;
false /*persistnamespace*/)
.setLogger(logger)
.setBuffered(false)) {
- cb::io::rmrf(data_dir.c_str());
+ try {
+ cb::io::rmrf(data_dir.c_str());
+ } catch (std::system_error& e) {
+ if (e.code() != std::error_code(ENOENT, std::system_category())) {
+ throw e;
+ }
+ }
kvstore.reset(new CouchKVStore(config, ops));
initialize_kv_store(kvstore.get());
}
0,
false /*persistnamespace*/)
.setBuffered(false)) {
- cb::io::rmrf(data_dir.c_str());
+ try {
+ cb::io::rmrf(data_dir.c_str());
+ } catch (std::system_error& e) {
+ if (e.code() != std::error_code(ENOENT, std::system_category())) {
+ throw e;
+ }
+ }
kvstore.reset(new MockCouchKVStore(config));
StatsCallback sc;
std::string failoverLog("");