]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: merge ceph-disk.sh activate dmcrypt functions
authorLoic Dachary <ldachary@redhat.com>
Wed, 1 Apr 2015 12:58:43 +0000 (14:58 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sun, 5 Apr 2015 23:58:18 +0000 (01:58 +0200)
The activate_dmcrypt_plain_dev_body and activate_dmcrypt_dev_body
functions are almost identical, merge them and differentiate with an
argument.

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

index efdc43e7f1e0ab44b33ab507d16f653406fe9620..326c65da35fa32188dd55519a301fb6c3069c7e9 100755 (executable)
@@ -236,47 +236,24 @@ function test_activate_dmcrypt() {
     local journal_p=$4
     local uuid=$5
     local juuid=$6
+    local plain=$7
 
     $mkdir -p $OSD_DATA
 
-    ./ceph-disk $CEPH_DISK_ARGS \
-               prepare --dmcrypt --dmcrypt-key-dir $DIR/keys --osd-uuid=$uuid --journal-uuid=$juuid $to_prepare $journal || return 1
-
-    /sbin/cryptsetup --key-file $DIR/keys/$uuid.luks.key luksOpen $to_activate $uuid
-    /sbin/cryptsetup --key-file $DIR/keys/$juuid.luks.key luksOpen ${journal}${journal_p} $juuid
-    
-    $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
-        activate \
-        --mark-init=none \
-        /dev/mapper/$uuid || return 1
-    $timeout $TIMEOUT ./ceph osd pool set $TEST_POOL size 1 || return 1
-
-    local id=$($cat $OSD_DATA/ceph-?/whoami || $cat $to_activate/whoami)
-    local weight=1
-    ./ceph osd crush add osd.$id $weight root=default host=localhost || return 1
-    echo FOO > $DIR/BAR
-    $timeout $TIMEOUT ./rados --pool $TEST_POOL put BAR $DIR/BAR || return 1
-    $timeout $TIMEOUT ./rados --pool $TEST_POOL get BAR $DIR/BAR.copy || return 1
-    $diff $DIR/BAR $DIR/BAR.copy || return 1
-}
-
-function test_activate_dmcrypt_plain() {
-    local to_prepare=$1
-    local to_activate=$2
-    local journal=$3
-    local journal_p=$4
-    local uuid=$5
-    local juuid=$6
-
-    $mkdir -p $OSD_DATA
-
-    echo "osd_dmcrypt_type=plain" > $DIR/ceph.conf
+    if test $plain = plain ; then
+        echo "osd_dmcrypt_type=plain" > $DIR/ceph.conf
+    fi
     
     ./ceph-disk $CEPH_DISK_ARGS \
                prepare --dmcrypt --dmcrypt-key-dir $DIR/keys --osd-uuid=$uuid --journal-uuid=$juuid $to_prepare $journal || return 1
 
-    /sbin/cryptsetup --key-file $DIR/keys/$uuid --key-size 256 create $uuid $to_activate
-    /sbin/cryptsetup --key-file $DIR/keys/$juuid --key-size 256 create $juuid $journal
+    if test $plain = plain ; then
+        /sbin/cryptsetup --key-file $DIR/keys/$uuid --key-size 256 create $uuid $to_activate
+        /sbin/cryptsetup --key-file $DIR/keys/$juuid --key-size 256 create $juuid $journal
+    else
+        /sbin/cryptsetup --key-file $DIR/keys/$uuid.luks.key luksOpen $to_activate $uuid
+        /sbin/cryptsetup --key-file $DIR/keys/$juuid.luks.key luksOpen ${journal}${journal_p} $juuid
+    fi
     
     $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
         activate \
@@ -528,7 +505,7 @@ function activate_dmcrypt_dev_body() {
 
     setup
     run_mon
-    test_activate_dmcrypt $disk ${disk}p1 $journal p1 $uuid $juuid|| return 1
+    test_activate_dmcrypt $disk ${disk}p1 $journal p1 $uuid $juuid not_plain || return 1
     kill_daemons
     umount /dev/mapper/$uuid || return 1
     teardown
@@ -566,7 +543,7 @@ function activate_dmcrypt_plain_dev_body() {
 
     setup
     run_mon
-    test_activate_dmcrypt_plain $disk ${disk}p1 $journal p1 $uuid $juuid|| return 1
+    test_activate_dmcrypt $disk ${disk}p1 $journal p1 $uuid $juuid plain || return 1
     kill_daemons
     umount /dev/mapper/$uuid || return 1
     teardown