Skip to content

Commit

Permalink
Merge pull request #6901 from yehudasa/wip-mstart
Browse files Browse the repository at this point in the history
vstart.sh: add mstart, mstop, mrun wrappers for running multiple vstart-style test clusters out of src tree

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Dec 11, 2015
2 parents b3ad2b9 + 8cc6301 commit 7f627e0
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/mrgw.sh
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

script_root=`dirname $0`

[ "$#" -lt 2 ] && echo "usage: $0 <name> <port> [params...]" && exit 1

name=$1
port=$2

shift 2

run_root=$script_root/run/$name
pidfile=$run_root/out/radosgw.${port}.pid

$script_root/mstop.sh $name radosgw $port

$script_root/mrun $name radosgw --rgw-frontends="civetweb port=$port" --pid-file=$pidfile "$@"
11 changes: 11 additions & 0 deletions src/mrun
@@ -0,0 +1,11 @@
#!/bin/sh

[ $# -lt 2 ] && echo "usage: $0 <name> <command> [params...]" && exit 1

root=`dirname $0`
run_name=$1
command=$2

shift 2

$root/$command -c $root/run/$run_name/ceph.conf "$@"
45 changes: 45 additions & 0 deletions src/mstart.sh
@@ -0,0 +1,45 @@
#!/bin/sh

usage="usage: $0 <name> [vstart options]..\n"

usage_exit() {
printf "$usage"
exit
}

[ $# -lt 1 ] && usage_exit


instance=$1
shift

root_path=`dirname $0`
root_path=`(cd $root_path; pwd)`
RUN_ROOT_PATH=${root_path}/run
CLUSTERS_LIST=$RUN_ROOT_PATH/.clusters.list

mkdir -p $RUN_ROOT_PATH


if [ ! -f $CLUSTERS_LIST ]; then
touch $CLUSTERS_LIST
fi

pos=`grep -n -w $instance $CLUSTERS_LIST`
if [ $? -ne 0 ]; then
echo $instance >> $CLUSTERS_LIST
pos=`grep -n -w $instance $CLUSTERS_LIST`
fi

pos=`echo $pos | cut -d: -f1`
base_port=$((6800+pos*10))

export VSTART_DEST=$RUN_ROOT_PATH/$instance
export CEPH_PORT=$base_port

mkdir -p $VSTART_DEST

echo "Cluster dest path: $VSTART_DEST"
echo "monitors base port: $CEPH_PORT"

$root_path/vstart.sh "$@"
43 changes: 43 additions & 0 deletions src/mstop.sh
@@ -0,0 +1,43 @@
#!/bin/bash

set -e

script_root=`dirname $0`

[ "$#" -lt 1 ] && echo "usage: $0 <name> [entity [id]]" && exit 1

name=$1
entity=$2
id=$3

run_root=$script_root/run/$name
pidpath=$run_root/out

if [ "$entity" == "" ]; then
pfiles=`ls $pidpath/*.pid` || true
elif [ "$id" == "" ]; then
pfiles=`ls $pidpath/$entity.*.pid` || true
else
pfiles=`ls $pidpath/$entity.$id.pid` || true
fi

for pidfile in $pfiles; do
pid=`cat $pidfile`
fname=`echo $pidfile | sed 's/.*\///g'`
echo $pid
[ "$pid" == "" ] && exit
[ $pid -eq 0 ] && exit
echo pid=$pid
extra_check=""
entity=`echo $fname | sed 's/\..*//g'`
[ "$entity" == "radosgw" ] && extra_check="-e lt-radosgw"
echo entity=$entity pid=$pid
while ps -p $pid -o args= | grep -q -e $entity $extracheck ; do
cmd="kill $signal $pid"
printf "$cmd..."
$cmd
sleep 1
continue
done
done

17 changes: 15 additions & 2 deletions src/vstart.sh
Expand Up @@ -3,6 +3,18 @@
# abort on failure
set -e

if [ -n "$VSTART_DEST" ]; then
SRC_PATH=`dirname $0`
SRC_PATH=`(cd $SRC_PATH; pwd)`

CEPH_DIR=$SRC_PATH
CEPH_BIN=$SRC_PATH
CEPH_LIB=$SRC_PATH/.libs
CEPH_CONF_PATH=$VSTART_DEST
CEPH_DEV_DIR=$VSTART_DEST/dev
CEPH_OUT_DIR=$VSTART_DEST/out
fi

if [ -e CMakeCache.txt ]; then
# Out of tree build, learn source location from CMakeCache.txt
SRC_ROOT=`grep Ceph_SOURCE_DIR CMakeCache.txt | cut -d "=" -f 2`
Expand Down Expand Up @@ -59,6 +71,7 @@ export DYLD_LIBRARY_PATH=$CEPH_LIB:$DYLD_LIBRARY_PATH
[ -z "$CEPH_DEV_DIR" ] && CEPH_DEV_DIR="$CEPH_DIR/dev"
[ -z "$CEPH_OUT_DIR" ] && CEPH_OUT_DIR="$CEPH_DIR/out"
[ -z "$CEPH_RGW_PORT" ] && CEPH_RGW_PORT=8000
[ -z "$CEPH_CONF_PATH" ] && CEPH_CONF_PATH=$CEPH_DIR

extra_conf=""
new=0
Expand All @@ -83,8 +96,8 @@ journal=1

MON_ADDR=""

conf_fn="$CEPH_DIR/ceph.conf"
keyring_fn="$CEPH_DIR/keyring"
conf_fn="$CEPH_CONF_PATH/ceph.conf"
keyring_fn="$CEPH_CONF_PATH/keyring"
osdmap_fn="/tmp/ceph_osdmap.$$"
monmap_fn="/tmp/ceph_monmap.$$"

Expand Down

0 comments on commit 7f627e0

Please sign in to comment.