diff options
author | Josh Durgin <josh.durgin@dreamhost.com> | 2012-04-24 08:35:43 -0700 |
---|---|---|
committer | Josh Durgin <josh.durgin@dreamhost.com> | 2012-04-24 08:57:31 -0700 |
commit | d28f850fe1d048349a50962f3b13ef1797cee45b (patch) | |
tree | 47a7e5db23bb334eb2730f4e02e9e1ccf470dca4 | |
parent | 7add136f907876a20aa2a68297c66b8259afd9a7 (diff) | |
download | ceph-d28f850fe1d048349a50962f3b13ef1797cee45b.tar.gz |
test_rbd: add tests for snap_set and more complicated resizing
* snap_set to a deleted (and recreated) snapshot
* resizing down (truncating) and back up
* resizing to non-object-aligned sizes
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
-rw-r--r-- | src/test/pybind/test_rbd.py | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index eb8d6f5a3b2..7edf8e97a26 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -4,8 +4,8 @@ import struct from nose import with_setup from nose.tools import eq_ as eq, assert_raises from rados import Rados -from rbd import RBD, Image, ImageNotFound, InvalidArgument, ImageExists, \ - ImageBusy +from rbd import (RBD, Image, ImageNotFound, InvalidArgument, ImageExists, + ImageBusy) rados = None @@ -130,6 +130,26 @@ class TestImage(object): info = self.image.stat() check_stat(info, new_size, IMG_ORDER) + def test_resize_down(self): + new_size = IMG_SIZE / 2 + data = rand_data(256) + self.image.write(data, IMG_SIZE / 2); + self.image.resize(new_size) + self.image.resize(IMG_SIZE) + read = self.image.read(IMG_SIZE / 2, 256) + eq('\0' * 256, read) + + def test_resize_bytes(self): + new_size = IMG_SIZE / 2 - 5 + data = rand_data(256) + self.image.write(data, IMG_SIZE / 2 - 10); + self.image.resize(new_size) + self.image.resize(IMG_SIZE) + read = self.image.read(IMG_SIZE / 2 - 10, 5) + eq(data[:5], read) + read = self.image.read(IMG_SIZE / 2 - 5, 251) + eq('\0' * 251, read) + def test_copy(self): global ioctx data = rand_data(256) @@ -286,3 +306,37 @@ class TestImage(object): eq(snap['name'], str(i)) for i in xrange(num_snaps): self.image.remove_snap(str(i)) + + def test_set_snap_deleted(self): + self.image.write('\0' * 256, 0) + self.image.create_snap('snap1') + read = self.image.read(0, 256) + eq(read, '\0' * 256) + data = rand_data(256) + self.image.write(data, 0) + read = self.image.read(0, 256) + eq(read, data) + self.image.set_snap('snap1') + self.image.remove_snap('snap1') + assert_raises(ImageNotFound, self.image.read, 0, 256) + self.image.set_snap(None) + read = self.image.read(0, 256) + eq(read, data) + + def test_set_snap_recreated(self): + self.image.write('\0' * 256, 0) + self.image.create_snap('snap1') + read = self.image.read(0, 256) + eq(read, '\0' * 256) + data = rand_data(256) + self.image.write(data, 0) + read = self.image.read(0, 256) + eq(read, data) + self.image.set_snap('snap1') + self.image.remove_snap('snap1') + self.image.create_snap('snap1') + assert_raises(ImageNotFound, self.image.read, 0, 256) + self.image.set_snap(None) + read = self.image.read(0, 256) + eq(read, data) + self.image.remove_snap('snap1') |