diff --git a/src/test/rgw/sfs/test_rgw_sfs_wal_checkpoint.cc b/src/test/rgw/sfs/test_rgw_sfs_wal_checkpoint.cc index f88810d569e854..c6e98109b6e9e3 100644 --- a/src/test/rgw/sfs/test_rgw_sfs_wal_checkpoint.cc +++ b/src/test/rgw/sfs/test_rgw_sfs_wal_checkpoint.cc @@ -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); @@ -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. @@ -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 @@ -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.