From b6ffdf18f2ce634f7a12c4e621525a07faba36c6 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 28 Oct 2010 14:31:22 -0700 Subject: [PATCH] qa: add basic rbd test --- qa/rbd/common.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ qa/rbd/rbd.sh | 20 ++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 qa/rbd/common.sh create mode 100755 qa/rbd/rbd.sh diff --git a/qa/rbd/common.sh b/qa/rbd/common.sh new file mode 100644 index 0000000000000..6c767e4f8224e --- /dev/null +++ b/qa/rbd/common.sh @@ -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 +} diff --git a/qa/rbd/rbd.sh b/qa/rbd/rbd.sh new file mode 100755 index 0000000000000..9b2a3bdc7f5fa --- /dev/null +++ b/qa/rbd/rbd.sh @@ -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 +