Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
rgw/sfs: testing: TestSFSWALCheckpoint: add init_store()
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Serong <[email protected]>
  • Loading branch information
tserong committed Oct 25, 2023
1 parent ea33ae7 commit 1e5aa11
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/test/rgw/sfs/test_rgw_sfs_wal_checkpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ class TestSFSWALCheckpoint : public ::testing::Test {
fs::create_directory(test_dir);
cct->_conf.set_val("rgw_sfs_data_path", test_dir);
cct->_log->start();
}

~TestSFSWALCheckpoint() override {
store.reset();
fs::remove_all(test_dir);
}

// Ordinarily this would just go in the TestSFSWALCheckpoint constructor.
// Unfortunately our tests need to tweak config settings that must be
// done _before_ the SFStore is created so that they're in place when
// DBConn's storage->on_open handler is invoked, so each test has to
// call this function explicitly.
void init_store() {
store.reset(new rgw::sal::SFStore(cct.get(), test_dir));

sqlite::SQLiteUsers users(store->db_conn);
Expand All @@ -58,11 +71,6 @@ class TestSFSWALCheckpoint : public ::testing::Test {
);
}

~TestSFSWALCheckpoint() override {
store.reset();
fs::remove_all(test_dir);
}

// This will spawn num_threads threads, each creating num_objects objects,
// and will record and return the maximum size the WAL reaches while this
// is ongoing.
Expand Down Expand Up @@ -102,6 +110,7 @@ class TestSFSWALCheckpoint : public ::testing::Test {
TEST_F(TestSFSWALCheckpoint, confirm_wal_explosion) {
cct->_conf.set_val("rgw_sfs_wal_checkpoint_use_sqlite_default", "true");
cct->_conf.set_val("rgw_sfs_wal_size_limit", "-1");
init_store();

// Using the SQLite default checkpointing mechanism with
// 10 concurrent writer threads will easily push us past
Expand All @@ -118,6 +127,8 @@ TEST_F(TestSFSWALCheckpoint, confirm_wal_explosion) {
// This test proves the WAL growth problem has been fixed
// by our SFS checkpoint mechanism.
TEST_F(TestSFSWALCheckpoint, test_wal_checkpoint) {
init_store();

// Using our SFS checkpoint mechanism, the WAL may exceed
// 16MB while writing, because the trunacte checkpoints
// don't always succeed, but it shouldn't go over by much.
Expand Down

0 comments on commit 1e5aa11

Please sign in to comment.