From 71e39a0307084d50a2bf654575a00ec83ca385f3 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Tue, 6 Aug 2024 13:24:02 +0200 Subject: [PATCH] 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 ] --- qa/workunits/rbd/luks-encryption.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 -- 2.47.3