diff options
author | songweibin <song.weibin@zte.com.cn> | 2017-12-06 09:51:49 +0100 |
---|---|---|
committer | songweibin <song.weibin@zte.com.cn> | 2017-12-08 16:58:16 +0100 |
commit | 9eff61bf52130387bd3111ff3ebc2f756530100c (patch) | |
tree | 8bf0f3dc40fd24f5f3e0447c8d840497d7653d78 /src/test/pybind | |
parent | Merge pull request #18276 from liewegas/wip-removed-snaps (diff) | |
download | ceph-9eff61bf52130387bd3111ff3ebc2f756530100c.tar.xz ceph-9eff61bf52130387bd3111ff3ebc2f756530100c.zip |
pybind/rbd: support open the image by image_id
We can initialize an image with image name or image id.
Signed-off-by: songweibin <song.weibin@zte.com.cn>
Diffstat (limited to 'src/test/pybind')
-rw-r--r-- | src/test/pybind/test_rbd.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index bd4005e0547..29b731b49ac 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -862,6 +862,35 @@ class TestImage(object): # watcher. eq(len(watchers), 1) +class TestImageId(object): + + def setUp(self): + self.rbd = RBD() + create_image() + self.image = Image(ioctx, image_name) + self.image2 = Image(ioctx, None, None, False, self.image.id()) + + def tearDown(self): + self.image.close() + self.image2.close() + remove_image() + self.image = None + self.image2 = None + + def test_read(self): + data = self.image2.read(0, 20) + eq(data, b'\0' * 20) + + def test_write(self): + data = rand_data(256) + self.image2.write(data, 0) + + def test_resize(self): + new_size = IMG_SIZE * 2 + self.image2.resize(new_size) + info = self.image2.stat() + check_stat(info, new_size, IMG_ORDER) + def check_diff(image, offset, length, from_snapshot, expected): extents = [] def cb(offset, length, exists): |