From: Loic Dachary Date: Tue, 7 Oct 2014 17:02:45 +0000 (+0200) Subject: ceph-disk: test prepare / activate on a device X-Git-Tag: v0.90~66^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=26bf8d1ecc4230cb685d50550fbd8f80edeef7e1;p=ceph.git ceph-disk: test prepare / activate on a device 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 --- diff --git a/src/test/Makefile.am b/src/test/Makefile.am index ce9110652e76..7b07de399181 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -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 index 000000000000..9b02398d5960 --- /dev/null +++ b/src/test/ceph-disk-root.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Copyright (C) 2014 Red Hat +# +# Author: Loic Dachary +# +# 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: diff --git a/src/test/ceph-disk.sh b/src/test/ceph-disk.sh index 081b1fb0562b..be03011438f1 100755 --- a/src/test/ceph-disk.sh +++ b/src/test/ceph-disk.sh @@ -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