]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd: perform cleanup in test_clone_encryption()
authorIlya Dryomov <idryomov@gmail.com>
Tue, 6 Aug 2024 11:24:02 +0000 (13:24 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 11 Aug 2024 08:45:38 +0000 (10:45 +0200)
... so that RAW_DEV can be unmapped and future tests can reuse testimg
and other image names without bumping into watchers and older snapshots.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 82d26909cb12b62d88f69f90eb8af692e497bddb)

 Conflicts:
qa/workunits/rbd/luks-encryption.sh [ commit 1d3de19c4005
  ("tools/rbd: add encryption format support for cloned image")
  not in quincy ]

qa/workunits/rbd/luks-encryption.sh

index 665862e32724115c7bdafebee6b5b9c78db4d2f4..49f7c6d8031ee0b5665dd002f43fc10377ea13d1 100755 (executable)
@@ -28,7 +28,6 @@ function drop_caches {
 
 function test_encryption_format() {
   local format=$1
-  clean_up_cryptsetup
 
   # format
   rbd encryption format testimg $format /tmp/passphrase
@@ -49,10 +48,13 @@ function test_encryption_format() {
   dd if=/tmp/testdata2 of=/dev/mapper/cryptsetupdev conv=fsync bs=1M
   dd if=$LIBRBD_DEV of=/tmp/cmpdata iflag=direct bs=4M count=4
   cmp -n 16MB /tmp/cmpdata /tmp/testdata2
+
+  _sudo rbd device unmap -t nbd $LIBRBD_DEV
+  sudo cryptsetup close cryptsetupdev
 }
 
 function get_nbd_device_paths {
-       rbd device list -t nbd | tail -n +2 | egrep "\s+rbd\s+testimg\s+" | awk '{print $5;}'
+  rbd device list -t nbd | tail -n +2 | egrep "\s+rbd\s+testimg" | awk '{print $5;}'
 }
 
 function clean_up_cryptsetup() {
@@ -62,8 +64,8 @@ function clean_up_cryptsetup() {
 function clean_up {
   sudo rm -f $TMP_FILES
   clean_up_cryptsetup
-       for device in $(get_nbd_device_paths); do
-         _sudo rbd device unmap -t nbd $device
+  for device in $(get_nbd_device_paths); do
+    _sudo rbd device unmap -t nbd $device
   done
        rbd ls | grep testimg > /dev/null && rbd rm testimg || true
 }
@@ -99,4 +101,7 @@ RAW_DEV=$(_sudo rbd -p rbd map testimg -t nbd)
 test_encryption_format luks1
 test_encryption_format luks2
 
+_sudo rbd device unmap -t nbd $RAW_DEV
+rbd rm testimg
+
 echo OK