From: Jason Dillaman Date: Wed, 17 Mar 2021 18:14:48 +0000 (-0400) Subject: test/pybind/rbd: fixed functional change in encryption API X-Git-Tag: v17.1.0~2565^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40194%2Fhead;p=ceph.git test/pybind/rbd: fixed functional change in encryption API The encryption format API now also implicitly loads the encryption layer. This tweaks the tests to account for this functional difference. Fixes: https://tracker.ceph.com/issues/49848 Signed-off-by: Jason Dillaman --- diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index 1bc6d9c5c4c8..75a19381199d 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -1362,23 +1362,43 @@ class TestImage(object): @require_linux() @blocklist_features([RBD_FEATURE_JOURNALING]) def test_encryption_luks1(self): - self.image.write(b'hello world', 0) - self.image.encryption_format(RBD_ENCRYPTION_FORMAT_LUKS1, "password") - read_bytes = self.image.read(0, 11) - assert_not_equal(b'hello world', read_bytes) - self.image.encryption_load(RBD_ENCRYPTION_FORMAT_LUKS1, "password") - assert_not_equal(read_bytes, self.image.read(0, 11)) + data = b'hello world' + offset = 16<<20 + image_size = 32<<20 + + with Image(ioctx, image_name) as image: + image.resize(image_size) + image.write(data, offset) + image.encryption_format(RBD_ENCRYPTION_FORMAT_LUKS1, "password") + assert_not_equal(data, image.read(offset, len(data))) + with Image(ioctx, image_name) as image: + image.encryption_load(RBD_ENCRYPTION_FORMAT_LUKS1, "password") + assert_not_equal(data, image.read(offset, len(data))) + image.write(data, offset) + with Image(ioctx, image_name) as image: + image.encryption_load(RBD_ENCRYPTION_FORMAT_LUKS1, "password") + eq(data, image.read(offset, len(data))) @require_linux() @blocklist_features([RBD_FEATURE_JOURNALING]) def test_encryption_luks2(self): - self.image.resize(256 << 20) - self.image.write(b'hello world', 0) - self.image.encryption_format(RBD_ENCRYPTION_FORMAT_LUKS2, "password") - read_bytes = self.image.read(0, 11) - assert_not_equal(b'hello world', read_bytes) - self.image.encryption_load(RBD_ENCRYPTION_FORMAT_LUKS2, "password") - assert_not_equal(read_bytes, self.image.read(0, 11)) + data = b'hello world' + offset = 16<<20 + image_size = 256<<20 + + with Image(ioctx, image_name) as image: + image.resize(image_size) + image.write(data, offset) + image.encryption_format(RBD_ENCRYPTION_FORMAT_LUKS2, "password") + assert_not_equal(data, image.read(offset, len(data))) + with Image(ioctx, image_name) as image: + image.encryption_load(RBD_ENCRYPTION_FORMAT_LUKS2, "password") + assert_not_equal(data, image.read(offset, len(data))) + image.write(data, offset) + with Image(ioctx, image_name) as image: + image.encryption_load(RBD_ENCRYPTION_FORMAT_LUKS2, "password") + eq(data, image.read(offset, len(data))) + class TestImageId(object):