]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/pybind/rbd: fixed functional change in encryption API
authorJason Dillaman <dillaman@redhat.com>
Wed, 17 Mar 2021 18:14:48 +0000 (14:14 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 18 Mar 2021 19:12:55 +0000 (15:12 -0400)
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 <dillaman@redhat.com>
(cherry picked from commit 625244f999a5ecaf908220d7bc68c81bab01cc6a)

src/test/pybind/test_rbd.py

index 1bc6d9c5c4c8fe7fb9b347de8b2db9279b3913c8..75a19381199d38d342f66e07630700f87f867176 100644 (file)
@@ -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):