From 2c2785b6969959d7358ca29ee38e8078fa887ff1 Mon Sep 17 00:00:00 2001 From: sajibreadd Date: Mon, 11 Aug 2025 10:46:39 +0200 Subject: [PATCH] Test failure: LibCephFS.SnapdiffDeletionRecreation Reproduces: https://tracker.ceph.com/issues/72518 Signed-off-by: Md Mahamudur Rahaman Sajib (cherry picked from commit 4ff71386ac1529dc1f7c2640511f509bd6842862) (cherry picked from commit 48f5a5d04fb2cef52c5e4a3daf452ccf988666d2) --- src/test/libcephfs/snapdiff.cc | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/test/libcephfs/snapdiff.cc b/src/test/libcephfs/snapdiff.cc index 2320bf58b6c..9b8c99f1eef 100644 --- a/src/test/libcephfs/snapdiff.cc +++ b/src/test/libcephfs/snapdiff.cc @@ -27,6 +27,7 @@ #include #include #include +#include using namespace std; class TestMount { @@ -1682,3 +1683,56 @@ TEST(LibCephFS, HugeSnapDiffLargeDelta) ASSERT_EQ(0, test_mount.rmsnap("snap1")); ASSERT_EQ(0, test_mount.rmsnap("snap2")); } +TEST(LibCephFS, SnapdiffDeletionRecreation) { + size_t bulk_count = 1 << 12; + TestMount test_mount("/SnapdiffDeletionRecreation"); + + ASSERT_EQ(0, test_mount.mkdir("bulk")); + ASSERT_EQ(0, test_mount.mkdir("test")); + + int i, j; + char path[PATH_MAX]; + for (i = 0; i < bulk_count; i++) { + snprintf(path, PATH_MAX - 1, "bulk/%d", i); + test_mount.write_full(path, path); + } + ASSERT_EQ(0, test_mount.mksnap("snap1")); + // creation of snap1 done + + for (i = 0; i < bulk_count / 2; ++i) { + snprintf(path, PATH_MAX - 1, "bulk/%d", i); + ASSERT_EQ(0, test_mount.unlink(path)); + if (i >= bulk_count / 4) { + ASSERT_EQ(0, test_mount.mkdir(path)); + } + } + for (i = bulk_count; i < 2 * bulk_count; ++i) { + snprintf(path, PATH_MAX - 1, "bulk/%d", i); + test_mount.write_full(path, path); + } + ASSERT_EQ(0, test_mount.mksnap("snap2")); + + uint64_t snapid1; + uint64_t snapid2; + + // learn snapshot ids and do basic verification + ASSERT_EQ(0, test_mount.get_snapid("snap1", &snapid1)); + ASSERT_EQ(0, test_mount.get_snapid("snap2", &snapid2)); + + vector > expected; + for (int i = 0; i < 2 * bulk_count; ++i) { + string dir = to_string(i); + if (i < bulk_count / 4) { + expected.push_back({dir, snapid1}); + } else if (i >= bulk_count / 4 && i < bulk_count / 2) { + expected.push_back({dir, snapid1}); + expected.push_back({dir, snapid2}); + } else if (i >= bulk_count) { + expected.push_back({dir, snapid2}); + } + } + test_mount.verify_snap_diff(expected, "bulk", "snap1", "snap2"); + + test_mount.rmsnap("snap1"); + test_mount.rmsnap("snap2"); +} -- 2.39.5