From: Mykola Golub Date: Mon, 10 Oct 2016 07:29:32 +0000 (+0300) Subject: qa/workunits/rbd: allow to start several daemons for the same cluster X-Git-Tag: v12.0.0~38^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7c21275f4f6a13aa009303038b71442ddc432f7a;p=ceph.git qa/workunits/rbd: allow to start several daemons for the same cluster by optionally specifyning daemon instance after cluster name and colon, like: start_mirror ${cluster}:${instance} Signed-off-by: Mykola Golub --- diff --git a/qa/workunits/rbd/rbd_mirror_helpers.sh b/qa/workunits/rbd/rbd_mirror_helpers.sh index 0937a28f8237..7d468aa2e410 100755 --- a/qa/workunits/rbd/rbd_mirror_helpers.sh +++ b/qa/workunits/rbd/rbd_mirror_helpers.sh @@ -99,26 +99,51 @@ fi # Functions # +# Parse a value in format cluster[:instance] and set cluster and instance vars. +set_cluster_instance() +{ + local val=$1 + local cluster_var_name=$2 + local instance_var_name=$3 + + cluster=${val%:*} + instance=${val##*:} + + if [ "${instance}" = "${val}" ]; then + # instance was not specified, use default + instance=0 + fi + + eval ${cluster_var_name}=${cluster} + eval ${instance_var_name}=${instance} +} + daemon_asok_file() { local local_cluster=$1 local cluster=$2 + local instance + + set_cluster_instance "${local_cluster}" local_cluster instance if [ -n "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then echo $(ceph-conf --cluster $local_cluster --name "client.${CEPH_ID}" 'admin socket') else - echo "${TEMPDIR}/rbd-mirror.${local_cluster}_daemon.${cluster}.asok" + echo "${TEMPDIR}/rbd-mirror.${local_cluster}_daemon.${instance}.${cluster}.asok" fi } daemon_pid_file() { local cluster=$1 + local instance + + set_cluster_instance "${cluster}" cluster instance if [ -n "${RBD_MIRROR_USE_RBD_MIRROR}" ]; then echo $(ceph-conf --cluster $cluster --name "client.${CEPH_ID}" 'pid file') else - echo "${TEMPDIR}/rbd-mirror.${cluster}_daemon.pid" + echo "${TEMPDIR}/rbd-mirror.${cluster}_daemon.${instance}.pid" fi } @@ -193,11 +218,15 @@ setup() cleanup() { test -n "${RBD_MIRROR_NOCLEANUP}" && return + local cluster instance set +e - stop_mirror "${CLUSTER1}" - stop_mirror "${CLUSTER2}" + for cluster in "${CLUSTER1}" "${CLUSTER2}"; do + for instance in `seq 0 9`; do + stop_mirror "${cluster}:${instance}" + done + done if [ -z "${RBD_MIRROR_USE_EXISTING_CLUSTER}" ]; then cd ${CEPH_ROOT} @@ -215,14 +244,17 @@ cleanup() start_mirror() { local cluster=$1 + local instance + + set_cluster_instance "${cluster}" cluster instance test -n "${RBD_MIRROR_USE_RBD_MIRROR}" && return rbd-mirror \ --cluster ${cluster} \ - --pid-file=$(daemon_pid_file "${cluster}") \ - --log-file=${TEMPDIR}/rbd-mirror.${cluster}_daemon.\$cluster.\$pid.log \ - --admin-socket=${TEMPDIR}/rbd-mirror.${cluster}_daemon.\$cluster.asok \ + --pid-file=$(daemon_pid_file "${cluster}:${instance}") \ + --log-file=${TEMPDIR}/rbd-mirror.${cluster}_daemon.${instance}.log \ + --admin-socket=${TEMPDIR}/rbd-mirror.${cluster}_daemon.${instance}.\$cluster.asok \ --rbd-mirror-journal-poll-age=1 \ --debug-rbd=30 --debug-journaler=30 \ --debug-rbd_mirror=30 \ @@ -255,8 +287,11 @@ stop_mirror() admin_daemon() { local cluster=$1 ; shift + local instance + + set_cluster_instance "${cluster}" cluster instance - local asok_file=$(daemon_asok_file "${cluster}" "${cluster}") + local asok_file=$(daemon_asok_file "${cluster}:${instance}" "${cluster}") test -S "${asok_file}" ceph --admin-daemon ${asok_file} $@