diff options
author | Qiaowei Ren <qiaowei.ren@intel.com> | 2018-01-04 13:43:33 +0800 |
---|---|---|
committer | Qiaowei Ren <qiaowei.ren@intel.com> | 2018-01-05 11:59:39 +0800 |
commit | 812ff6ca9fcd3e629e49d4328905f33eee8ca3f5 (patch) | |
tree | 04ece7b4da00d9d2f98093774594f4057ae561d4 /src/ceph/qa/rbd | |
parent | 15280273faafb77777eab341909a3f495cf248d9 (diff) |
initial code repo
This patch creates initial code repo.
For ceph, luminous stable release will be used for base code,
and next changes and optimization for ceph will be added to it.
For opensds, currently any changes can be upstreamed into original
opensds repo (https://github.com/opensds/opensds), and so stor4nfv
will directly clone opensds code to deploy stor4nfv environment.
And the scripts for deployment based on ceph and opensds will be
put into 'ci' directory.
Change-Id: I46a32218884c75dda2936337604ff03c554648e4
Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Diffstat (limited to 'src/ceph/qa/rbd')
-rw-r--r-- | src/ceph/qa/rbd/common.sh | 103 | ||||
-rwxr-xr-x | src/ceph/qa/rbd/rbd.sh | 49 |
2 files changed, 152 insertions, 0 deletions
diff --git a/src/ceph/qa/rbd/common.sh b/src/ceph/qa/rbd/common.sh new file mode 100644 index 0000000..e1926f7 --- /dev/null +++ b/src/ceph/qa/rbd/common.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +die() { + echo "$*" + exit 1 +} + +cleanup() { + rm -rf $TDIR + TDIR="" +} + +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" + + CCONF="ceph-conf -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 + + [ -z "$imgsize" ] && imgsize=1024 + [ -z "$user" ] && user=admin + [ -z "$keyring" ] && keyring="`$CCONF keyring`" + [ -z "$secret" ] && secret="`ceph-authtool $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" ] && die "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() { + id=$1 + rbd create $img_name.$id --size=$imgsize +} + +rbd_add() { + id=$1 + echo "$monip:$monport name=$user,secret=$secret rbd $img_name.$id" \ + > /sys/bus/rbd/add + + pushd /sys/bus/rbd/devices &> /dev/null + [ $? -eq 0 ] || die "failed to cd" + devid="" + rm -f "$TDIR/rbd_devs" + for f in *; do echo $f >> "$TDIR/rbd_devs"; done + sort -nr "$TDIR/rbd_devs" > "$TDIR/rev_rbd_devs" + while read f < "$TDIR/rev_rbd_devs"; do + read d_img_name < "$f/name" + if [ "x$d_img_name" == "x$img_name.$id" ]; then + devid=$f + break + fi + done + popd &> /dev/null + + [ "x$devid" == "x" ] && die "failed to find $img_name.$id" + + export rbd$id=$devid + while [ ! -e /dev/rbd$devid ]; do sleep 1; done +} + +rbd_test_init() { + rbd_load +} + +rbd_remove() { + echo $1 > /sys/bus/rbd/remove +} + +rbd_rm_image() { + id=$1 + rbd rm $imgname.$id +} + +TDIR=`mktemp -d` +trap cleanup INT TERM EXIT +set_variables diff --git a/src/ceph/qa/rbd/rbd.sh b/src/ceph/qa/rbd/rbd.sh new file mode 100755 index 0000000..1ef67e6 --- /dev/null +++ b/src/ceph/qa/rbd/rbd.sh @@ -0,0 +1,49 @@ +#!/bin/bash -x + +basedir=`echo $0 | sed 's/[^/]*$//g'`. +. $basedir/common.sh + +rbd_test_init + + +create_multiple() { + for i in `seq 1 10`; do + rbd_create_image $i + done + + for i in `seq 1 10`; do + rbd_add $i + done + for i in `seq 1 10`; do + devname=/dev/rbd`eval echo \\$rbd$i` + echo $devname + done + for i in `seq 1 10`; do + devid=`eval echo \\$rbd$i` + rbd_remove $devid + done + for i in `seq 1 10`; do + rbd_rm_image $i + done +} + +test_dbench() { + rbd_create_image 0 + 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 + rbd_rm_image 0 +} + +create_multiple +test_dbench + |