From: Ilya Dryomov Date: Tue, 6 Aug 2024 11:24:02 +0000 (+0200) Subject: qa/workunits/rbd: perform cleanup in test_clone_encryption() X-Git-Tag: v17.2.8~169^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=71e39a0307084d50a2bf654575a00ec83ca385f3;p=ceph.git qa/workunits/rbd: perform cleanup in test_clone_encryption() ... 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 (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 ] --- diff --git a/qa/workunits/rbd/luks-encryption.sh b/qa/workunits/rbd/luks-encryption.sh index 665862e3272..49f7c6d8031 100755 --- a/qa/workunits/rbd/luks-encryption.sh +++ b/qa/workunits/rbd/luks-encryption.sh @@ -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