]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/rbd: minor fixes
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 29 Dec 2010 23:36:22 +0000 (15:36 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 29 Dec 2010 23:36:22 +0000 (15:36 -0800)
* qa/rbd/common: create tempdir for script

* qa/rbd/common: try harder to find monhost (try "mon addr" and also
"mon.a addr")

* qa/rbd/rbd.sh: honor $mnt parameter

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
qa/rbd/common.sh
qa/rbd/rbd.sh

index e716ed3b77e4ba6e284e155ec963d62296f9de92..606e39a49b931ef51db632d677a4707dbabd4303 100644 (file)
@@ -1,40 +1,54 @@
+#!/bin/bash
 
-error_exit() {
+die() {
        echo "$*"
        exit 1
 }
 
-# defaults
-[ -z "$bindir" ] && bindir=$PWD       # location of init-ceph
-if [ -z "$conf" ]; then
-       conf="$basedir/ceph.conf"
-       [ -e $conf ] || conf="/etc/ceph/ceph.conf"
-fi
-[ -e $conf ] || error_exit "conf file not found"
+cleanup() {
+    rm -rf $TDIR
+    TDIR=""
+}
 
-CCONF="cconf -c $conf"
+set_variables() {
+    # defaults
+    [ -z "$bindir" ] && bindir=$PWD       # location of init-ceph
+    if [ -z "$conf" ]; then
+        conf="$basedir/ceph.conf"
+        [ -e $conf ] || conf="/etc/ceph/ceph.conf"
+    fi
+    [ -e $conf ] || die "conf file not found"
 
-[ -z "$mnt" ] && mnt="/c"
-[ -z "$monhost" ] && monhost="`$CCONF -t mon -i 0 'mon addr'`"
-[ -z "$imgsize" ] && imgsize=1024
-[ -z "$user" ] && user=admin
-[ -z "$keyring" ] && keyring="`$CCONF keyring`"
-[ -z "$secret" ] && secret="`cauthtool $keyring -n client.$user -p`"
+    CCONF="cconf -c $conf"
 
+    [ -z "$mnt" ] && mnt="/c"
+    if [ -z "$monhost" ]; then
+        $CCONF -t mon -i 0 'mon addr' > $TDIR/cconf_mon
+        if [ $? -ne 0 ]; then
+            $CCONF -t mon.a -i 0 'mon addr' > $TDIR/cconf_mon
+            [ $? -ne 0 ] && die "can't figure out \$monhost"
+        fi
+        read monhost < $TDIR/cconf_mon
+    fi
 
-monip="`echo $monhost | sed 's/:/ /g' | awk '{print $1}'`"
-monport="`echo $monhost | sed 's/:/ /g' | awk '{print $2}'`"
+    [ -z "$imgsize" ] && imgsize=1024
+    [ -z "$user" ] && user=admin
+    [ -z "$keyring" ] && keyring="`$CCONF keyring`"
+    [ -z "$secret" ] && secret="`cauthtool $keyring -n client.$user -p`"
 
-[ -z "$monip" ] && error_exit "bad mon address"
+    monip="`echo $monhost | sed 's/:/ /g' | awk '{print $1}'`"
+    monport="`echo $monhost | sed 's/:/ /g' | awk '{print $2}'`"
 
-[ -z "$monport" ] && monport=6789
+    [ -z "$monip" ] && die "bad mon address"
 
-set -e
+    [ -z "$monport" ] && monport=6789
 
-mydir=`hostname`_`echo $0 | sed 's/\//_/g'`
+    set -e
 
-img_name=test.`hostname`.$$
+    mydir=`hostname`_`echo $0 | sed 's/\//_/g'`
 
+    img_name=test.`hostname`.$$
+}
 
 rbd_load() {
        modprobe rbd
@@ -57,7 +71,6 @@ rbd_test_init() {
        rbd_load
 }
 
-
 rbd_remove() {
        echo $1 > /sys/class/rbd/remove
 }
@@ -66,3 +79,7 @@ rbd_rm_image() {
        id=$1
        rbd rm $imgname.$id
 }
+
+TDIR=`mktemp -d`
+trap cleanup INT TERM EXIT
+set_variables
index b90f0c2cfbbfee72f340ec15ec3f561fbcc075bc..1ef67e6c2ee53ade68b6f7776768eb3cb3341939 100755 (executable)
@@ -34,12 +34,12 @@ test_dbench() {
        devname=/dev/rbd$rbd0
 
        mkfs -t ext3 $devname
-       mount -t ext3 $devname /mnt
+       mount -t ext3 $devname $mnt
 
-       dbench -D /mnt -t 30 5
+       dbench -D $mnt -t 30 5
        sync
 
-       umount /mnt
+       umount $mnt
        rbd_remove $rbd0
        rbd_rm_image 0
 }