]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: ceph-disk.sh dmcrypt tests use test_setup_dev_and_run
authorLoic Dachary <ldachary@redhat.com>
Wed, 1 Apr 2015 13:01:25 +0000 (15:01 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sun, 5 Apr 2015 23:58:19 +0000 (01:58 +0200)
Instead of duplicating the device construction / destruction logic for
dmcrypt tests, use test_setup_dev_and_run to do it. It is now able to
recover from devmapper leftover which may occur when a cryptsetup test
fails.

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/test/ceph-disk.sh

index 326c65da35fa32188dd55519a301fb6c3069c7e9..c9f7169639a11bad024627d8f05daead3cb5b0e2 100755 (executable)
@@ -482,20 +482,6 @@ function test_setup_dev_and_run() {
     return $status
 }
 
-function destroy_dmcrypt_dev() {
-    local name=$1
-    local dev=$2
-    local uuid=$3
-
-    for partition in 1 2 3 4 ; do
-        umount /dev/mapper/$uuid || true
-       /sbin/cryptsetup remove /dev/mapper/$uuid || true
-       dmsetup remove /dev/mapper/$uuid || true
-    done
-    losetup --detach $dev
-    rm $name
-}
-
 function activate_dmcrypt_dev_body() {
     local disk=$1
     local journal=$2
@@ -512,26 +498,7 @@ function activate_dmcrypt_dev_body() {
 }
 
 function test_activate_dmcrypt_dev() {
-    if test $(id -u) != 0 ; then
-        echo "SKIP because not root"
-        return 0
-    fi
-
-    loop_sanity_check || return 1
-
-    local disk=$(create_dev vdf.disk)
-    local journal=$(create_dev vdg.disk)
-    local newdisk=$(create_dev vdh.disk)
-
-    activate_dmcrypt_dev_body $disk $journal $newdisk
-    status=$?
-    test $status != 0 && teardown
-
-    destroy_dmcrypt_dev vdf.disk $disk
-    destroy_dmcrypt_dev vdg.disk $journal
-    destroy_dmcrypt_dev vdh.disk $newdisk
-
-    return $status
+    test_setup_dev_and_run activate_dmcrypt_dev_body
 }
 
 function activate_dmcrypt_plain_dev_body() {
@@ -550,23 +517,7 @@ function activate_dmcrypt_plain_dev_body() {
 }
 
 function test_activate_dmcrypt_plain_dev() {
-    if test $(id -u) != 0 ; then
-        echo "SKIP because not root"
-        return 0
-    fi
-
-    local disk=$(create_dev vdf.disk)
-    local journal=$(create_dev vdg.disk)
-    local newdisk=$(create_dev vdh.disk)
-
-    activate_dmcrypt_plain_dev_body $disk $journal $newdisk
-    status=$?
-
-    destroy_dmcrypt_dev vdf.disk $disk
-    destroy_dmcrypt_dev vdg.disk $journal
-    destroy_dmcrypt_dev vdh.disk $newdisk
-
-    return $status
+    test_setup_dev_and_run activate_dmcrypt_plain_dev_body
 }
 
 function test_find_cluster_by_uuid() {