mirror of
https://github.com/ceph/ceph
synced 2025-02-24 19:47:44 +00:00
cls_rbd: get_features needs to support legacy negative tests
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>
This commit is contained in:
parent
b142c92344
commit
66493b7e83
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user