]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: test prepare / activate on a device
authorLoic Dachary <loic-201408@dachary.org>
Tue, 7 Oct 2014 17:02:45 +0000 (19:02 +0200)
committerLoic Dachary <ldachary@redhat.com>
Tue, 18 Nov 2014 11:20:01 +0000 (12:20 +0100)
This indirectly tests that partprobe is called after zap because it
would fail to map the partitions to /dev/disk/by-partuuid otherwise.

It also indirectly test the implementation of init=none when using a
block device because the test would fail to put an object into the rbd
pool using the device otherwise.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
src/test/Makefile.am
src/test/ceph-disk-root.sh [new file with mode: 0755]
src/test/ceph-disk.sh

index ce9110652e7688d53f473e31336597a8b9a86737..7b07de399181f913010f3c00b6ed151356c023b0 100644 (file)
@@ -251,6 +251,7 @@ check_SCRIPTS += \
        test/osd/osd-config.sh \
        test/osd/osd-bench.sh \
        test/ceph-disk.sh \
+       test/ceph-disk-root.sh \
        test/mon/mon-handle-forward.sh
 
 EXTRA_DIST += \
diff --git a/src/test/ceph-disk-root.sh b/src/test/ceph-disk-root.sh
new file mode 100755 (executable)
index 0000000..9b02398
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 Red Hat <contact@redhat.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+source test/docker-test-helper.sh
+
+supported='([ubuntu]="14.04" [centos]="centos7")'
+main_docker "$@" --all "$supported" --compile
+main_docker "$@" --all "$supported" --user root --dev test/ceph-disk.sh test_activate_dev
+
+# Local Variables:
+# compile-command: "cd ../.. ; make -j4 && test/osd/ceph-disk-root.sh"
+# End:
index 081b1fb0562b9e6bad3103b00226a50b0aa2fec4..be03011438f1146a15c40d4ddd08b79121a95714 100755 (executable)
@@ -23,6 +23,7 @@ PS4='${FUNCNAME[0]}: $LINENO: '
 
 export PATH=:$PATH # make sure program from sources are prefered
 DIR=test-ceph-disk
+OSD_DATA=$DIR/osd
 MON_ID=a
 MONA=127.0.0.1:7451
 TEST_POOL=rbd
@@ -37,6 +38,7 @@ CEPH_ARGS+=" --log-file=$DIR/\$name.log"
 CEPH_ARGS+=" --pid-file=$DIR/\$name.pidfile"
 CEPH_ARGS+=" --osd-pool-default-erasure-code-directory=.libs"
 CEPH_ARGS+=" --auth-supported=none"
+CEPH_ARGS+=" --osd-journal-size=100"
 CEPH_DISK_ARGS=
 CEPH_DISK_ARGS+=" --statedir=$DIR"
 CEPH_DISK_ARGS+=" --sysconfdir=$DIR"
@@ -47,11 +49,15 @@ TIMEOUT=360
 cat=$(which cat)
 timeout=$(which timeout)
 diff=$(which diff)
+mkdir=$(which mkdir)
+rm=$(which rm)
 
 function setup() {
     teardown
     mkdir $DIR
-    touch $DIR/ceph.conf
+    mkdir $OSD_DATA
+#    mkdir $OSD_DATA/ceph-0
+    touch $DIR/ceph.conf # so ceph-disk think ceph is the cluster
 }
 
 function teardown() {
@@ -162,7 +168,7 @@ function test_no_path() {
 }
 
 # ceph-disk prepare returns immediately on success if the magic file
-# exists on the --osd-data directory.
+# exists in the --osd-data directory.
 function test_activate_dir_magic() {
     local uuid=$(uuidgen)
     local osd_data=$DIR/osd
@@ -192,22 +198,22 @@ function test_activate_dir_magic() {
     grep --quiet $uuid $osd_data/ceph_fsid || return 1
 }
 
-function test_activate_dir() {
-    run_mon
+function test_activate() {
+    local to_prepare=$1
+    local to_activate=$2
 
-    local osd_data=$DIR/osd
+    $mkdir -p $OSD_DATA
 
-    /bin/mkdir -p $osd_data
     ./ceph-disk $CEPH_DISK_ARGS \
-        prepare $osd_data || return 1
+        prepare $to_prepare || return 1
 
-    CEPH_ARGS="$CEPH_ARGS --osd-journal-size=100 --osd-data=$osd_data" \
-        $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
-                      activate \
-                     --mark-init=none \
-                    $osd_data || return 1
+    $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
+        activate \
+        --mark-init=none \
+        $to_activate || return 1
     $timeout $TIMEOUT ./ceph osd pool set $TEST_POOL size 1 || return 1
-    local id=$($cat $osd_data/whoami)
+
+    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
@@ -216,6 +222,37 @@ function test_activate_dir() {
     $diff $DIR/BAR $DIR/BAR.copy || return 1
 }
 
+function test_activate_dir() {
+    run_mon
+
+    local osd_data=$DIR/dir
+    $mkdir -p $osd_data
+    test_activate $osd_data $osd_data || return 1
+    $rm -fr $osd_data
+}
+
+function test_activate_dev() {
+    run_mon
+
+    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:)
+    ./ceph-disk zap $disk
+    test_activate ${disk} ${disk}p1
+    kill_daemons
+    umount ${disk}p1
+    ./ceph-disk zap $disk
+    status=$?
+    losetup --detach $disk
+    rm vde.disk
+    return $status
+}
+
 function test_find_cluster_by_uuid() {
     setup
     test_activate_dir 2>&1 | tee $DIR/test_find