Skip to content

Commit

Permalink
qa: add basic rbd test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehuda Sadeh committed Oct 28, 2010
1 parent 66e1d9f commit b6ffdf1
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
62 changes: 62 additions & 0 deletions qa/rbd/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

error_exit() {
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"

CCONF="cconf -c $conf"

[ -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`"


monip="`echo $monhost | sed 's/:/ /g' | awk '{print $1}'`"
monport="`echo $monhost | sed 's/:/ /g' | awk '{print $2}'`"

[ -z "$monip" ] && error_exit "bad mon address"

[ -z "$monport" ] && monport=6789

set -e

mydir=`hostname`_`echo $0 | sed 's/\//_/g'`

img_name=test.`hostname`.$$


rbd_load() {
modprobe rbd
}

rbd_create_image() {
rbd create $img_name --size=$imgsize
}

rbd_add() {
id=$1
echo "$monip:$monport name=$user,secret=$secret rbd $img_name" > /sys/class/rbd/add
sleep 1
export rbd$id="`tail -1 /sys/class/rbd/list | cut -f1`"
}

rbd_test_init() {
rbd_load
rbd_create_image
}


rbd_remove() {
echo $1 > /sys/class/rbd/remove
}
20 changes: 20 additions & 0 deletions qa/rbd/rbd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -x

basedir=`echo $0 | sed 's/[^/]*$//g'`.
. $basedir/common.sh

rbd_test_init

rbd_add 0

devname=/dev/rbd$rbd0

mkfs -t ext3 $devname
mount -t ext3 $devname /mnt

dbench -D /mnt -t 30 5
sync

umount /mnt
rbd_remove $rbd0

0 comments on commit b6ffdf1

Please sign in to comment.