]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: test re-using an existing journal partition
authorDan van der Ster <daniel.vanderster@cern.ch>
Fri, 12 Dec 2014 11:40:19 +0000 (12:40 +0100)
committerLoic Dachary <ldachary@redhat.com>
Sat, 13 Dec 2014 14:01:45 +0000 (15:01 +0100)
Add a ceph-disk test to first setup an OSD with a separate journal
block device, then tear down the OSD (simulating a failure) and create
a new OSD which re-uses the same journal device.

Add create_dev / destroy_dev helpers that encapsulate the operations
that ensure the partition table is up to date in the kernel and the
symlinks are created as expected. In particular it makes sure the kernel
is aware that the partition table of a newly created device is
empty. If the device previously existed and the kernel was not informed
of the latest partition table updates via partprobe / partx, it may
have cached an old partition table which can create all sorts of
unexpected behaviors such as a failure to create the by-partuuid
symbolic links as described in http://tracker.ceph.com/issues/10146
Refs: #10146

Signed-off-by: Dan van der Ster <daniel.vanderster@cern.ch>
Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/test/ceph-disk.sh

index 1ed38cb5b8d69c84db1c1431ea98c306bc07ad97..1466d0c4ea6e1a4133707527a4193848aef74e4b 100755 (executable)
@@ -201,11 +201,12 @@ function test_activate_dir_magic() {
 function test_activate() {
     local to_prepare=$1
     local to_activate=$2
+    local journal=$3
 
     $mkdir -p $OSD_DATA
 
     ./ceph-disk $CEPH_DISK_ARGS \
-        prepare $to_prepare || return 1
+        prepare $to_prepare $journal || return 1
 
     $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
         activate \
@@ -231,31 +232,65 @@ function test_activate_dir() {
     $rm -fr $osd_data
 }
 
+function create_dev() {
+    local name=$1
+
+    dd if=/dev/zero of=$name bs=1024k count=200
+    losetup --find $name
+    local dev=$(losetup --associated $name | cut -f1 -d:)
+    ceph-disk zap $dev > /dev/null 2>&1
+    echo $dev
+}
+
+function destroy_dev() {
+    local name=$1
+    local dev=$2
+
+    for partition in 1 2 3 4 ; do
+        umount ${dev}p${partition} || true
+    done
+    losetup --detach $dev
+    rm $name
+}
+
 function activate_dev_body() {
     local disk=$1
+    local journal=$2
+    local newdisk=$3
 
-    ./ceph-disk zap $disk || return 1
-    test_activate ${disk} ${disk}p1 || return 1
+    setup
+    run_mon
+    test_activate $disk ${disk}p1 $journal || return 1
     kill_daemons
     umount ${disk}p1 || return 1
-    ./ceph-disk zap $disk || return 1
-}
+    teardown
 
-function test_activate_dev() {
+    # reuse the journal partition
+    setup
     run_mon
+    test_activate $newdisk ${newdisk}p1 ${journal}p1 || return 1
+    kill_daemons
+    umount ${newdisk}p1 || return 1
+    teardown
+}
 
+function test_activate_dev() {
     if test $(id -u) != 0 ; then
         echo "SKIP because not root"
         return 0
     fi
 
-    dd if=/dev/zero of=vde.disk bs=1024k count=200
-    losetup --find vde.disk
-    local disk=$(losetup --associated vde.disk | cut -f1 -d:)
-    activate_dev_body $disk
+    local disk=$(create_dev vdf.disk)
+    local journal=$(create_dev vdg.disk)
+    local newdisk=$(create_dev vdh.disk)
+
+    activate_dev_body $disk $journal $newdisk
     status=$?
-    losetup --detach $disk
-    rm vde.disk
+
+    destroy_dev vdf.disk $disk
+    destroy_dev vdg.disk $journal
+    destroy_dev vdh.disk $newdisk
+
     return $status
 }