]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/cls_rbd/test_cls_rbd: update TestClsRbd.sparsify 30258/head
authorKefu Chai <kchai@redhat.com>
Mon, 9 Sep 2019 10:39:41 +0000 (18:39 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 9 Sep 2019 13:44:53 +0000 (21:44 +0800)
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>
src/test/cls_rbd/test_cls_rbd.cc

index 724bfa21ebf9b8d2c5b6b1286c09a7491ed945d1..9a4adccc964d168d75da66c7e8ef63620d24541d 100644 (file)
@@ -3141,13 +3141,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));