From 17d6a993fc17d533460c5f40f3908c708e057c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 23 May 2024 18:45:17 +0200 Subject: Merging upstream version 18.2.3. Signed-off-by: Daniel Baumann --- src/test/librados/snapshots_cxx.cc | 60 +++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) (limited to 'src/test/librados/snapshots_cxx.cc') diff --git a/src/test/librados/snapshots_cxx.cc b/src/test/librados/snapshots_cxx.cc index 8098b2cb7..95dbe5da0 100644 --- a/src/test/librados/snapshots_cxx.cc +++ b/src/test/librados/snapshots_cxx.cc @@ -25,9 +25,9 @@ TEST_F(LibRadosSnapshotsPP, SnapListPP) { bufferlist bl1; bl1.append(buf, sizeof(buf)); ASSERT_EQ(0, ioctx.write("foo", bl1, sizeof(buf), 0)); - ASSERT_FALSE(cluster.get_pool_is_selfmanaged_snaps_mode(pool_name)); + ASSERT_EQ(0, cluster.pool_is_in_selfmanaged_snaps_mode(pool_name)); ASSERT_EQ(0, ioctx.snap_create("snap1")); - ASSERT_FALSE(cluster.get_pool_is_selfmanaged_snaps_mode(pool_name)); + ASSERT_EQ(0, cluster.pool_is_in_selfmanaged_snaps_mode(pool_name)); std::vector snaps; EXPECT_EQ(0, ioctx.snap_list(&snaps)); EXPECT_EQ(1U, snaps.size()); @@ -35,7 +35,7 @@ TEST_F(LibRadosSnapshotsPP, SnapListPP) { EXPECT_EQ(0, ioctx.snap_lookup("snap1", &rid)); EXPECT_EQ(rid, snaps[0]); EXPECT_EQ(0, ioctx.snap_remove("snap1")); - ASSERT_FALSE(cluster.get_pool_is_selfmanaged_snaps_mode(pool_name)); + ASSERT_EQ(0, cluster.pool_is_in_selfmanaged_snaps_mode(pool_name)); } TEST_F(LibRadosSnapshotsPP, SnapRemovePP) { @@ -109,9 +109,9 @@ TEST_F(LibRadosSnapshotsPP, SnapCreateRemovePP) { TEST_F(LibRadosSnapshotsSelfManagedPP, SnapPP) { std::vector my_snaps; my_snaps.push_back(-2); - ASSERT_FALSE(cluster.get_pool_is_selfmanaged_snaps_mode(pool_name)); + ASSERT_EQ(0, cluster.pool_is_in_selfmanaged_snaps_mode(pool_name)); ASSERT_EQ(0, ioctx.selfmanaged_snap_create(&my_snaps.back())); - ASSERT_TRUE(cluster.get_pool_is_selfmanaged_snaps_mode(pool_name)); + ASSERT_EQ(1, cluster.pool_is_in_selfmanaged_snaps_mode(pool_name)); ::std::reverse(my_snaps.begin(), my_snaps.end()); ASSERT_EQ(0, ioctx.selfmanaged_snap_set_write_ctx(my_snaps[0], my_snaps)); ::std::reverse(my_snaps.begin(), my_snaps.end()); @@ -148,7 +148,7 @@ TEST_F(LibRadosSnapshotsSelfManagedPP, SnapPP) { ASSERT_EQ(0, ioctx.selfmanaged_snap_remove(my_snaps.back())); my_snaps.pop_back(); ioctx.snap_set_read(LIBRADOS_SNAP_HEAD); - ASSERT_TRUE(cluster.get_pool_is_selfmanaged_snaps_mode(pool_name)); + ASSERT_EQ(1, cluster.pool_is_in_selfmanaged_snaps_mode(pool_name)); ASSERT_EQ(0, ioctx.remove("foo")); } @@ -509,7 +509,7 @@ TEST_F(LibRadosSnapshotsSelfManagedPP, ReusePurgedSnap) { std::vector my_snaps; my_snaps.push_back(-2); ASSERT_EQ(0, ioctx.selfmanaged_snap_create(&my_snaps.back())); - ASSERT_TRUE(cluster.get_pool_is_selfmanaged_snaps_mode(pool_name)); + ASSERT_EQ(1, cluster.pool_is_in_selfmanaged_snaps_mode(pool_name)); ::std::reverse(my_snaps.begin(), my_snaps.end()); ASSERT_EQ(0, ioctx.selfmanaged_snap_set_write_ctx(my_snaps[0], my_snaps)); ::std::reverse(my_snaps.begin(), my_snaps.end()); @@ -548,6 +548,52 @@ TEST_F(LibRadosSnapshotsSelfManagedPP, ReusePurgedSnap) { //sleep(600); } +TEST(LibRadosPoolIsInSelfmanagedSnapsMode, NotConnected) { + librados::Rados cluster; + ASSERT_EQ(0, cluster.init(nullptr)); + + EXPECT_EQ(-ENOTCONN, cluster.pool_is_in_selfmanaged_snaps_mode("foo")); +} + +TEST(LibRadosPoolIsInSelfmanagedSnapsMode, FreshInstance) { + librados::Rados cluster1; + std::string pool_name = get_temp_pool_name(); + ASSERT_EQ("", create_one_pool_pp(pool_name, cluster1)); + EXPECT_EQ(0, cluster1.pool_is_in_selfmanaged_snaps_mode(pool_name)); + { + librados::Rados cluster2; + ASSERT_EQ("", connect_cluster_pp(cluster2)); + EXPECT_EQ(0, cluster2.pool_is_in_selfmanaged_snaps_mode(pool_name)); + } + + librados::IoCtx ioctx; + cluster1.ioctx_create(pool_name.c_str(), ioctx); + uint64_t snap_id; + ASSERT_EQ(0, ioctx.selfmanaged_snap_create(&snap_id)); + EXPECT_EQ(1, cluster1.pool_is_in_selfmanaged_snaps_mode(pool_name)); + { + librados::Rados cluster2; + ASSERT_EQ("", connect_cluster_pp(cluster2)); + EXPECT_EQ(1, cluster2.pool_is_in_selfmanaged_snaps_mode(pool_name)); + } + + ASSERT_EQ(0, ioctx.selfmanaged_snap_remove(snap_id)); + EXPECT_EQ(1, cluster1.pool_is_in_selfmanaged_snaps_mode(pool_name)); + { + librados::Rados cluster2; + ASSERT_EQ("", connect_cluster_pp(cluster2)); + EXPECT_EQ(1, cluster2.pool_is_in_selfmanaged_snaps_mode(pool_name)); + } + + ASSERT_EQ(0, cluster1.pool_delete(pool_name.c_str())); + EXPECT_EQ(-ENOENT, cluster1.pool_is_in_selfmanaged_snaps_mode(pool_name)); + { + librados::Rados cluster2; + ASSERT_EQ("", connect_cluster_pp(cluster2)); + EXPECT_EQ(-ENOENT, cluster2.pool_is_in_selfmanaged_snaps_mode(pool_name)); + } +} + // EC testing TEST_F(LibRadosSnapshotsECPP, SnapListPP) { SKIP_IF_CRIMSON(); -- cgit v1.2.3