diff options
author | songweibin <song.weibin@zte.com.cn> | 2017-10-31 11:25:59 +0100 |
---|---|---|
committer | songweibin <song.weibin@zte.com.cn> | 2017-11-14 07:17:03 +0100 |
commit | 9d9a27652fb3bb5cceebe054082651ee3692793b (patch) | |
tree | 8a0467eef8120e58cd37c79f29a30fd3ff1e9a36 /src/test/pybind | |
parent | librbd: fix rbd children listing when child is in trash bin (diff) | |
download | ceph-9d9a27652fb3bb5cceebe054082651ee3692793b.tar.xz ceph-9d9a27652fb3bb5cceebe054082651ee3692793b.zip |
librbd: add new API methods and expand the rbd CLI to list trashed images
implement librbd::RBD::list_children2 and rbd_list_children2
methods and expand the rbd CLI to list trashed images
Signed-off-by: songweibin <song.weibin@zte.com.cn>
Diffstat (limited to 'src/test/pybind')
-rw-r--r-- | src/test/pybind/test_rbd.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index e72045a5918..f46f09cedcf 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -1043,32 +1043,74 @@ class TestClone(object): deduped = set([(pool_name, image[1]) for image in actual]) eq(deduped, set(expected)) + def check_children2(self, expected): + actual = list(self.image.list_children2()) + eq(actual, expected) + + def get_image_id(self, ioctx, name): + with Image(ioctx, name) as image: + return image.id() + def test_list_children(self): global ioctx global features self.image.set_snap('snap1') self.check_children([(pool_name, self.clone_name)]) + self.check_children2( + [{'pool': pool_name, 'image': self.clone_name, 'trash': False, + 'id': self.get_image_id(ioctx, self.clone_name)}]) self.clone.close() self.rbd.remove(ioctx, self.clone_name) eq(self.image.list_children(), []) + eq(list(self.image.list_children2()), []) clone_name = get_temp_image_name() + '_' expected_children = [] + expected_children2 = [] for i in range(10): self.rbd.clone(ioctx, image_name, 'snap1', ioctx, clone_name + str(i), features) expected_children.append((pool_name, clone_name + str(i))) + expected_children2.append( + {'pool': pool_name, 'image': clone_name + str(i), 'trash': False, + 'id': self.get_image_id(ioctx, clone_name + str(i))}) self.check_children(expected_children) + self.check_children2(expected_children2) + + image6_id = self.get_image_id(ioctx, clone_name + str(5)) + RBD().trash_move(ioctx, clone_name + str(5), 0) + expected_children.remove((pool_name, clone_name + str(5))) + for item in expected_children2: + for k, v in item.items(): + if v == image6_id: + item["trash"] = True + self.check_children(expected_children) + self.check_children2(expected_children2) + + RBD().trash_restore(ioctx, image6_id, clone_name + str(5)) + expected_children.append((pool_name, clone_name + str(5))) + for item in expected_children2: + for k, v in item.items(): + if v == image6_id: + item["trash"] = False + self.check_children(expected_children) + self.check_children2(expected_children2) for i in range(10): self.rbd.remove(ioctx, clone_name + str(i)) - expected_children.pop(0) + expected_children.remove((pool_name, clone_name + str(i))) + expected_children2.pop(0) self.check_children(expected_children) + self.check_children2(expected_children2) eq(self.image.list_children(), []) + eq(list(self.image.list_children2()), []) self.rbd.clone(ioctx, image_name, 'snap1', ioctx, self.clone_name, features) self.check_children([(pool_name, self.clone_name)]) + self.check_children2( + [{'pool': pool_name, 'image': self.clone_name, 'trash': False, + 'id': self.get_image_id(ioctx, self.clone_name)}]) self.clone = Image(ioctx, self.clone_name) def test_flatten_errors(self): |