diff options
author | Matan Breizman <mbreizma@redhat.com> | 2023-03-15 12:11:47 +0100 |
---|---|---|
committer | Matan Breizman <mbreizma@redhat.com> | 2023-03-21 13:58:24 +0100 |
commit | 047c1832c41afc3ce17c724375a6817fa1672b67 (patch) | |
tree | 2ef82eca952f4dd527d0957c6b03964695424c1a /src/test/librados | |
parent | crimson/osd/pg_backend: Rename clone_obc to resolved_obc (diff) | |
download | ceph-047c1832c41afc3ce17c724375a6817fa1672b67.tar.xz ceph-047c1832c41afc3ce17c724375a6817fa1672b67.zip |
test/librados/snapshots: Add FutureSnapRollback test
Add a test we rollback to a future snap id. Meaning, no mutation is
followed after taking the third snapshot.
The read op is expected to be applied to the head object.
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
Diffstat (limited to 'src/test/librados')
-rw-r--r-- | src/test/librados/snapshots.cc | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/test/librados/snapshots.cc b/src/test/librados/snapshots.cc index ab508de184f..275ec467a3c 100644 --- a/src/test/librados/snapshots.cc +++ b/src/test/librados/snapshots.cc @@ -127,7 +127,6 @@ TEST_F(LibRadosSnapshotsSelfManaged, Snap) { } TEST_F(LibRadosSnapshotsSelfManaged, Rollback) { - SKIP_IF_CRIMSON(); std::vector<uint64_t> my_snaps; my_snaps.push_back(-2); ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_create(ioctx, &my_snaps.back())); @@ -137,6 +136,7 @@ TEST_F(LibRadosSnapshotsSelfManaged, Rollback) { ::std::reverse(my_snaps.begin(), my_snaps.end()); char buf[bufsize]; memset(buf, 0xcc, sizeof(buf)); + // First write ASSERT_EQ(0, rados_write(ioctx, "foo", buf, sizeof(buf), 0)); my_snaps.push_back(-2); @@ -147,7 +147,9 @@ TEST_F(LibRadosSnapshotsSelfManaged, Rollback) { ::std::reverse(my_snaps.begin(), my_snaps.end()); char buf2[sizeof(buf)]; memset(buf2, 0xdd, sizeof(buf2)); + // Second write ASSERT_EQ(0, rados_write(ioctx, "foo", buf2, sizeof(buf2), 0)); + // Rollback to my_snaps[1] - Object is expeceted to conatin the first write rados_ioctx_selfmanaged_snap_rollback(ioctx, "foo", my_snaps[1]); char buf3[sizeof(buf)]; ASSERT_EQ((int)sizeof(buf3), rados_read(ioctx, "foo", buf3, sizeof(buf3), 0)); @@ -160,6 +162,51 @@ TEST_F(LibRadosSnapshotsSelfManaged, Rollback) { ASSERT_EQ(0, rados_remove(ioctx, "foo")); } +TEST_F(LibRadosSnapshotsSelfManaged, FutureSnapRollback) { + std::vector<uint64_t> my_snaps; + // Snapshot 1 + my_snaps.push_back(-2); + ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_create(ioctx, &my_snaps.back())); + ::std::reverse(my_snaps.begin(), my_snaps.end()); + ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_set_write_ctx(ioctx, my_snaps[0], + &my_snaps[0], my_snaps.size())); + ::std::reverse(my_snaps.begin(), my_snaps.end()); + char buf[bufsize]; + memset(buf, 0xcc, sizeof(buf)); + // First write + ASSERT_EQ(0, rados_write(ioctx, "foo", buf, sizeof(buf), 0)); + + // Snapshot 2 + my_snaps.push_back(-2); + ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_create(ioctx, &my_snaps.back())); + ::std::reverse(my_snaps.begin(), my_snaps.end()); + ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_set_write_ctx(ioctx, my_snaps[0], + &my_snaps[0], my_snaps.size())); + ::std::reverse(my_snaps.begin(), my_snaps.end()); + char buf2[sizeof(buf)]; + memset(buf2, 0xdd, sizeof(buf2)); + // Second write + ASSERT_EQ(0, rados_write(ioctx, "foo", buf2, sizeof(buf2), 0)); + // Snapshot 3 + my_snaps.push_back(-2); + ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_create(ioctx, &my_snaps.back())); + + // Rollback to the last snap id - Object is expected to conatin + // latest write (head object) + rados_ioctx_selfmanaged_snap_rollback(ioctx, "foo", my_snaps[2]); + char buf3[sizeof(buf)]; + ASSERT_EQ((int)sizeof(buf3), rados_read(ioctx, "foo", buf3, sizeof(buf3), 0)); + ASSERT_EQ(0, memcmp(buf3, buf2, sizeof(buf))); + + ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_remove(ioctx, my_snaps.back())); + my_snaps.pop_back(); + ASSERT_EQ(0, rados_ioctx_selfmanaged_snap_remove(ioctx, my_snaps.back())); + my_snaps.pop_back(); + ASSERT_EQ(0, rados_remove(ioctx, "foo")); +} + + + // EC testing TEST_F(LibRadosSnapshotsEC, SnapList) { SKIP_IF_CRIMSON(); |