]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_rbd: get_features needs to support legacy negative tests 4405/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 20 Apr 2015 16:40:33 +0000 (12:40 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 20 Apr 2015 16:40:33 +0000 (12:40 -0400)
During Ceph upgrade testing, older Ceph test suites assume that
get_features will return -ENOENT if provided a missing snapshot.
Support these negative tests until the older releases are no
longer supported.

Fixes: #11380
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/rbd/cls_rbd.cc
src/test/cls_rbd/test_cls_rbd.cc

index 42207da86abf067889cf2ba776d85661e10391a4..cbd14061b081ac1095d043bb31d3e077607321be 100644 (file)
@@ -296,11 +296,11 @@ int create(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
  */
 int get_features(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 {
+  uint64_t snap_id;
   bool read_only = false;
 
   bufferlist::iterator iter = in->begin();
   try {
-    uint64_t snap_id;
     ::decode(snap_id, iter);
     if (!iter.end()) {
       ::decode(read_only, iter);
@@ -309,7 +309,21 @@ int get_features(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
     return -EINVAL;
   }
 
-  CLS_LOG(20, "get_features read_only=%d", read_only);
+  CLS_LOG(20, "get_features snap_id=%" PRIu64 ", read_only=%d",
+          snap_id, read_only);
+
+  // NOTE: keep this deprecated snapshot logic to support negative
+  // test cases in older (pre-Infernalis) releases. Remove once older
+  // releases are no longer supported.
+  if (snap_id != CEPH_NOSNAP) {
+    cls_rbd_snap snap;
+    string snapshot_key;
+    key_from_snap_id(snap_id, &snapshot_key);
+    int r = read_key(hctx, snapshot_key, &snap);
+    if (r < 0) {
+      return r;
+    }
+  }
 
   uint64_t features;
   int r = read_key(hctx, "features", &features);
index bf971aea57f0c80e080abc99637e979c22d448b3..12e330a23d7804efeeb0901dabd4561d6e560295 100644 (file)
@@ -368,8 +368,13 @@ TEST_F(TestClsRbd, get_features)
   ASSERT_EQ(0, get_features(&ioctx, oid, CEPH_NOSNAP, &features));
   ASSERT_EQ(0u, features);
 
-  ASSERT_EQ(0, get_features(&ioctx, oid, 1, &features));
-  ASSERT_EQ(0u, features);
+  int r = get_features(&ioctx, oid, 1, &features);
+  if (r == 0) {
+    ASSERT_EQ(0u, features);
+  } else {
+    // deprecated snapshot handling
+    ASSERT_EQ(-ENOENT, r);
+  }
 
   ioctx.close();
 }