Skip to content

Commit 7b0d302

Browse files
committed
MB-71838: Replace std::filesystem::remove_all
Replace all instances of std::filesystem::remove_all() with the custom cb::io::remove_with_retry() function across test and benchmark files. This provides better retry behavior and error handling for directory removal operations. Change-Id: I14aebd07d793133394b6815caedfe10d036d9409 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/244909 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Jim Walker <jim@couchbase.com>
1 parent a840ad6 commit 7b0d302

28 files changed

Lines changed: 59 additions & 72 deletions

auditd/tests/auditconfig_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AuditConfigTest : public ::testing::Test {
2323
}
2424

2525
static void TearDownTestCase() {
26-
std::filesystem::remove_all(testdir);
26+
cb::io::remove_with_retry(testdir);
2727
}
2828

2929
nlohmann::json json;

auditd/tests/auditfile_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AuditFileTest : public ::testing::Test {
4040
}
4141

4242
void TearDown() override {
43-
std::filesystem::remove_all(testdir);
43+
cb::io::remove_with_retry(testdir);
4444
}
4545

4646
nlohmann::json create_audit_event() {

daemon/bucket_manager_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BucketManagerTest : public ::testing::Test, public BucketManager {
3636
}
3737

3838
void TearDown() override {
39-
remove_all(bucketPath);
39+
cb::io::remove_with_retry(bucketPath);
4040
}
4141

4242
static void SetUpTestSuite() {
@@ -52,7 +52,7 @@ class BucketManagerTest : public ::testing::Test, public BucketManager {
5252
if (is_directory(p.path(), ec)) {
5353
if (p.path().filename().string().starts_with(
5454
"BucketManagerTest")) {
55-
remove_all(p.path(), ec);
55+
cb::io::remove_with_retry(p.path(), ec);
5656
}
5757
}
5858
}

daemon/bucket_metering_stats_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BucketMeteringStatsTest : public ::testing::Test {
3636
if (is_directory(p.path(), ec)) {
3737
if (p.path().filename().string().starts_with(
3838
"BucketMeteringStatsTest")) {
39-
remove_all(p.path(), ec);
39+
cb::io::remove_with_retry(p.path(), ec);
4040
}
4141
}
4242
}
@@ -63,7 +63,7 @@ class BucketMeteringStatsTest : public ::testing::Test {
6363

6464
void TearDown() override {
6565
BucketManager::instance().destroyAll();
66-
remove_all(bucketPath);
66+
cb::io::remove_with_retry(bucketPath);
6767
}
6868

6969
Bucket* bucket = nullptr;

daemon/bucket_stats_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BucketStatsTest : public ::testing::Test {
3535
void TearDown() override {
3636
// destroy the bucket which was created for this test
3737
BucketManager::instance().doBlockingDestroy(cookie, "foobar", true, {});
38-
remove_all(bucketPath);
38+
cb::io::remove_with_retry(bucketPath);
3939
}
4040

4141
Bucket* bucket = nullptr;

engines/ep/benchmarks/engine_fixture.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void EngineFixture::TearDown(const benchmark::State& state) {
5555
engine->getDcpConnMap().manageConnections();
5656
engine.reset();
5757
ExecutorPool::shutdown();
58-
std::filesystem::remove_all("benchmarks-test");
58+
cb::io::remove_with_retry("benchmarks-test");
5959
}
6060
ObjectRegistry::onSwitchThread(nullptr);
6161
}

engines/ep/benchmarks/kvstore_bench.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class KVStoreBench : public benchmark::Fixture {
107107
gsl::narrow_cast<uint16_t>(workload.getNumShards()),
108108
shardId);
109109

110-
std::filesystem::remove_all(kvstoreConfig->getDBName());
110+
cb::io::remove_with_retry(kvstoreConfig->getDBName());
111111
std::filesystem::create_directories(kvstoreConfig->getDBName());
112112
kvstore = setup_kv_store(*kvstoreConfig);
113113

@@ -135,7 +135,7 @@ class KVStoreBench : public benchmark::Fixture {
135135

136136
void TearDown(const benchmark::State& state) override {
137137
kvstore.reset();
138-
std::filesystem::remove_all(kvstoreConfig->getDBName());
138+
cb::io::remove_with_retry(kvstoreConfig->getDBName());
139139
}
140140

141141
private:

engines/ep/src/access_scanner.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ItemAccessVisitor::ItemAccessVisitor(
7272
// (e.g. due to a crash). We *don't* want to use the common
7373
// method removeFile, as we can't continue running the visitor
7474
// if we failed to remove the file.
75-
std::filesystem::remove_all(next);
75+
cb::io::remove_with_retry(next);
7676
} catch (const std::exception& e) {
7777
EP_LOG_WARN_CTX("Failed to remove existing access log",
7878
{"path", next},

engines/ep/tests/ep_testsuite.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8130,7 +8130,7 @@ static test_result test_reader_thread_starvation_warmup(EngineIface* h) {
81308130
verify_curr_items(slowBucket, keysPerVbucket, "after warmup");
81318131
// 12. Ensure the buckets are destroyed and shutdown at the end of the test
81328132
testHarness->destroy_bucket(smallBucket, true);
8133-
std::filesystem::remove_all(smallBucketDir);
8133+
cb::io::remove_with_retry(smallBucketDir);
81348134
testHarness->destroy_bucket(slowBucket, true);
81358135
return SUCCESS;
81368136
}

engines/ep/tests/ep_testsuite_common.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static enum test_result skipped_test_function(EngineIface*) {
119119
}
120120

121121
enum test_result rmdb(std::string_view path) {
122-
std::filesystem::remove_all(path);
122+
cb::io::remove_with_retry(path);
123123
return SUCCESS;
124124
}
125125

0 commit comments

Comments
 (0)