]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Test failure: LibCephFS.SnapdiffDeletionRecreation
authorsajibreadd <sajibreadd@gmail.com>
Mon, 11 Aug 2025 08:46:39 +0000 (10:46 +0200)
committerIgor Fedotov <igor.fedotov@croit.io>
Tue, 9 Sep 2025 10:21:56 +0000 (13:21 +0300)
Reproduces: https://tracker.ceph.com/issues/72518
Signed-off-by: Md Mahamudur Rahaman Sajib <mahamudur.sajib@croit.io>
(cherry picked from commit 4ff71386ac1529dc1f7c2640511f509bd6842862)
(cherry picked from commit 48f5a5d04fb2cef52c5e4a3daf452ccf988666d2)

src/test/libcephfs/snapdiff.cc

index 2320bf58b6c2f354e0cc81457a5cb21334f24761..9b8c99f1eef855497b0714f0e8d82b7f9b347b77 100644 (file)
@@ -27,6 +27,7 @@
 #include <algorithm>
 #include <limits.h>
 #include <dirent.h>
+#include <random>
 
 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 <pair <string, uint64_t>> 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");
+}