diff --git a/src/test/rgw/sfs/test_rgw_sfs_concurrency.cc b/src/test/rgw/sfs/test_rgw_sfs_concurrency.cc index 087910d95b09d..24aef8acc2e87 100644 --- a/src/test/rgw/sfs/test_rgw_sfs_concurrency.cc +++ b/src/test/rgw/sfs/test_rgw_sfs_concurrency.cc @@ -66,7 +66,6 @@ class TestSFSConcurrency const fs::path database_directory; std::unique_ptr store; - sqlite::DBConnRef dbconn; BucketRef bucket; ObjectRef predef_object; sqlite::DBVersionedObject predef_db_object; @@ -81,16 +80,15 @@ class TestSFSConcurrency } void SetUp() override { ASSERT_TRUE(fs::exists(database_directory)) << database_directory; - dbconn = std::make_shared(cct.get()); store.reset(new rgw::sal::SFStore(cct.get(), database_directory)); - sqlite::SQLiteUsers users(dbconn); + sqlite::SQLiteUsers users(store->db_conn); sqlite::DBOPUserInfo user; user.uinfo.user_id.id = "testuser"; user.uinfo.display_name = "display_name"; users.store_user(user); - sqlite::SQLiteBuckets db_buckets(dbconn); + sqlite::SQLiteBuckets db_buckets(store->db_conn); sqlite::DBOPBucketInfo db_binfo; db_binfo.binfo.bucket = rgw_bucket("", "testbucket", "1234"); db_binfo.binfo.owner = rgw_user("testuser"); @@ -107,7 +105,7 @@ class TestSFSConcurrency predef_object = bucket->create_version(rgw_obj_key("predef_object")); predef_object->metadata_finish(store.get(), false); - sqlite::SQLiteVersionedObjects svos(dbconn); + sqlite::SQLiteVersionedObjects svos(store->db_conn); predef_db_object = svos.get_versioned_object(predef_object->version_id).value(); @@ -126,7 +124,6 @@ class TestSFSConcurrency void TearDown() override { store.reset(); - dbconn.reset(); fs::remove_all(database_directory); } @@ -192,7 +189,7 @@ class TestSFSConcurrency ); } - sqlite::Storage& storage() { return dbconn->get_storage(); } + sqlite::Storage& storage() { return store->db_conn->get_storage(); } }; TEST_P(TestSFSConcurrency, parallel_executions_must_not_throw) { diff --git a/src/test/rgw/sfs/test_rgw_sfs_object_state_machine.cc b/src/test/rgw/sfs/test_rgw_sfs_object_state_machine.cc index 292144e09ccd2..c164611695444 100644 --- a/src/test/rgw/sfs/test_rgw_sfs_object_state_machine.cc +++ b/src/test/rgw/sfs/test_rgw_sfs_object_state_machine.cc @@ -83,7 +83,7 @@ class TestSFSObjectStateMachine : public ::testing::Test { } fs::path getDBFullPath() const { return getDBFullPath(getTestDir()); } - sqlite::DBConnRef dbconn() { return std::make_shared(cct); } + sqlite::DBConnRef dbconn() { return store->db_conn; } sqlite::Storage& storage() { return dbconn()->get_storage(); } ObjectState database_object_state(ObjectRef obj) { return storage() diff --git a/src/test/rgw/sfs/test_rgw_sfs_sqlite_list.cc b/src/test/rgw/sfs/test_rgw_sfs_sqlite_list.cc index 8b9ba665353e6..266365ed3c6fd 100644 --- a/src/test/rgw/sfs/test_rgw_sfs_sqlite_list.cc +++ b/src/test/rgw/sfs/test_rgw_sfs_sqlite_list.cc @@ -40,7 +40,6 @@ class TestSFSList : public ::testing::Test { const fs::path database_directory; std::unique_ptr store; - DBConnRef dbconn; TestSFSList() : cct(new CephContext(CEPH_ENTITY_TYPE_ANY)), @@ -52,16 +51,15 @@ class TestSFSList : public ::testing::Test { } void SetUp() override { ASSERT_TRUE(fs::exists(database_directory)) << database_directory; - dbconn = std::make_shared(cct.get()); store.reset(new rgw::sal::SFStore(cct.get(), database_directory)); - SQLiteUsers users(dbconn); + SQLiteUsers users(store->db_conn); DBOPUserInfo user; user.uinfo.user_id.id = "testuser"; user.uinfo.display_name = "display_name"; users.store_user(user); - SQLiteBuckets db_buckets(dbconn); + SQLiteBuckets db_buckets(store->db_conn); DBOPBucketInfo db_binfo; db_binfo.binfo.bucket = rgw_bucket("", "testbucket", "testbucket"); db_binfo.binfo.owner = rgw_user("testuser"); @@ -77,7 +75,6 @@ class TestSFSList : public ::testing::Test { dump_db(); } store.reset(); - dbconn.reset(); fs::remove_all(database_directory); } @@ -95,17 +92,17 @@ class TestSFSList : public ::testing::Test { std::string name(prefix); name.append(gen_rand_alphanumeric(cct.get(), 23)); const auto obj = create_test_object("testbucket", name); - SQLiteObjects os(dbconn); + SQLiteObjects os(store->db_conn); os.store_object(obj); auto ver = create_test_versionedobject(obj.uuid, "testversion"); ver.object_state = version_state; - SQLiteVersionedObjects vos(dbconn); + SQLiteVersionedObjects vos(store->db_conn); vos.insert_versioned_object(ver); return std::make_pair(obj, ver); } void dump_db() { - auto& storage = dbconn->get_storage(); + auto& storage = store->db_conn->get_storage(); lderr(cct.get()) << "Dumping objects:" << dendl; for (const auto& row : storage.get_all()) { lderr(cct.get()) << row << dendl; @@ -122,7 +119,7 @@ class TestSFSList : public ::testing::Test { return e; } - SQLiteList make_uut() { return SQLiteList(dbconn); } + SQLiteList make_uut() { return SQLiteList(store->db_conn); } }; class TestSFSListObjectsAndVersions @@ -308,7 +305,7 @@ TEST_F(TestSFSList, objects__does_not_return_objects_with_delete_marker) { auto del = create_test_versionedobject(oov.first.uuid, "deletemarker"); del.object_state = rgw::sal::sfs::ObjectState::COMMITTED; del.version_type = rgw::sal::sfs::VersionType::DELETE_MARKER; - SQLiteVersionedObjects vos(dbconn); + SQLiteVersionedObjects vos(store->db_conn); vos.insert_versioned_object(del); ASSERT_TRUE(uut.objects("testbucket", "", "", 1000, results)); @@ -333,7 +330,7 @@ TEST_F(TestSFSList, versions__returns_versions_and_delete_markers) { auto del = create_test_versionedobject(oov.first.uuid, "deletemarker"); del.object_state = rgw::sal::sfs::ObjectState::COMMITTED; del.version_type = rgw::sal::sfs::VersionType::DELETE_MARKER; - SQLiteVersionedObjects vos(dbconn); + SQLiteVersionedObjects vos(store->db_conn); vos.insert_versioned_object(del); ASSERT_TRUE(uut.versions("testbucket", "", "", 1000, results)); @@ -350,8 +347,8 @@ TEST_F(TestSFSList, versions__correctly_sorts_and_marks_latest_version) { std::vector results; const auto obj = create_test_object("testbucket", "obj"); - SQLiteObjects os(dbconn); - SQLiteVersionedObjects vos(dbconn); + SQLiteObjects os(store->db_conn); + SQLiteVersionedObjects vos(store->db_conn); os.store_object(obj); auto latest = create_test_versionedobject(obj.uuid, "latest"); latest.object_state = rgw::sal::sfs::ObjectState::COMMITTED; @@ -385,8 +382,8 @@ TEST_F(TestSFSList, versions__there_is_latest_with_multiple_versions) { const auto obj1 = create_test_object("testbucket", "test1/a"); const auto obj2 = create_test_object("testbucket", "test2/abc"); - SQLiteObjects os(dbconn); - SQLiteVersionedObjects vos(dbconn); + SQLiteObjects os(store->db_conn); + SQLiteVersionedObjects vos(store->db_conn); os.store_object(obj1); os.store_object(obj2); std::array vers_obj1 = { @@ -434,8 +431,8 @@ TEST_F(TestSFSList, versions__only_one_latest) { std::vector results; const auto obj = create_test_object("testbucket", "test1/a"); - SQLiteObjects os(dbconn); - SQLiteVersionedObjects vos(dbconn); + SQLiteObjects os(store->db_conn); + SQLiteVersionedObjects vos(store->db_conn); os.store_object(obj); auto vo1 = create_test_versionedobject( obj.uuid, gen_rand_alphanumeric(cct.get(), 23) @@ -464,8 +461,8 @@ TEST_F(TestSFSList, versions__delete_marker_latest) { std::vector results; const auto obj = create_test_object("testbucket", "test1/a"); - SQLiteObjects os(dbconn); - SQLiteVersionedObjects vos(dbconn); + SQLiteObjects os(store->db_conn); + SQLiteVersionedObjects vos(store->db_conn); os.store_object(obj); auto vo1 = create_test_versionedobject( obj.uuid, gen_rand_alphanumeric(cct.get(), 23)