From 4529adc02c25c99aca8a3fb901eec156677f4a71 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 17 Mar 2021 14:14:48 -0400 Subject: [PATCH] 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 (cherry picked from commit 625244f999a5ecaf908220d7bc68c81bab01cc6a) --- src/test/pybind/test_rbd.py | 46 ++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index 1bc6d9c5c4c8f..75a19381199d3 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): -- 2.39.5