]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/cls_rbd/test_cls_rbd: update TestClsRbd.sparsify 30354/head
authorKefu Chai <kchai@redhat.com>
Mon, 9 Sep 2019 10:39:41 +0000 (18:39 +0800)
committerPrashant D <pdhange@redhat.com>
Thu, 12 Sep 2019 03:42:35 +0000 (23:42 -0400)
after #30061, extents returned by sparse read will always be
an empty map as long as the extents to be read is empty or the extent(s)
in it are empty, even of the objectstorage does not support sparse read.

Fixes: https://tracker.ceph.com/issues/41721
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 855d84d283124a0e2264172e849632317810556a)

src/test/cls_rbd/test_cls_rbd.cc

index b3ee9e44a12b9b869fbe13cfb384fe0c99e72337..05f8f364544da77aa4d2584a67db349bd3de0e3c 100644 (file)
@@ -3073,13 +3073,20 @@ TEST_F(TestClsRbd, sparsify)
   ASSERT_EQ(0, sparsify(&ioctx, oid, 16, false));
   std::map<uint64_t, uint64_t> m;
   bufferlist outbl;
-  std::map<uint64_t, uint64_t> expected_m = {{0, 0}};
+  std::map<uint64_t, uint64_t> expected_m;
   bufferlist expected_outbl;
-  if (sparse_read_supported) {
+  switch (int r = ioctx.sparse_read(oid, m, outbl, inbl.length(), 0); r) {
+  case 0:
     expected_m = {};
+    ASSERT_EQ(expected_m, m);
+    break;
+  case 1:
+    expected_m = {{0, 0}};
+    ASSERT_EQ(expected_m, m);
+    break;
+  default:
+    FAIL() << r << " is odd";
   }
-  ASSERT_EQ((int)expected_m.size(),
-            ioctx.sparse_read(oid, m, outbl, inbl.length(), 0));
   ASSERT_EQ(m, expected_m);
   ASSERT_EQ(0, sparsify(&ioctx, oid, 16, true));
   ASSERT_EQ(-ENOENT, sparsify(&ioctx, oid, 16, true));