]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd: add env vars to adapt rbd_mirror.sh to teuthology
authorJosh Durgin <jdurgin@redhat.com>
Sat, 2 Apr 2016 01:15:33 +0000 (18:15 -0700)
committerJason Dillaman <dillaman@redhat.com>
Tue, 10 May 2016 17:05:14 +0000 (13:05 -0400)
With these set, this script can work in teuthology, where we want to
control the how daemons run and their log locations, valgrind
settings, etc. The workunit task always sets CEPH_ID, and allows
other env vars to be configured optionally.

The RBD_MIRROR_USE_EXISTING_CLUSTER option can also speed up local testing.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
(cherry picked from commit dcd11a1f262e0c56bb1b37d54283cda06abbf4c7)

qa/workunits/rbd/rbd_mirror.sh

index f3eb002c8dd75b580640312cffd26498edd33ea3..fc549186aa79fc23010bc61b5cc8dc1b68cab8c3 100755 (executable)
@@ -66,6 +66,15 @@ POOL=mirror
 SRC_DIR=$(readlink -f $(dirname $0)/../../../src)
 TEMPDIR=
 
+# These vars facilitate running this script in an environment with
+# ceph installed from packages, like teuthology. These are not defined
+# by default.
+#
+# RBD_MIRROR_USE_EXISTING_CLUSTER - if set, do not start and stop ceph clusters
+# RBD_MIRROR_USE_EXISTING_DAEMON - if set, use an existing instance of rbd-mirror
+#                                  running as ceph client $CEPH_ID. If empty,
+#                                  this script will start and stop rbd-mirror
+
 #
 # Functions
 #
@@ -75,14 +84,22 @@ daemon_asok_file()
     local local_cluster=$1
     local cluster=$2
 
-    echo "${TEMPDIR}/rbd-mirror.${local_cluster}_daemon.${cluster}.asok"
+    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"
+    fi
 }
 
 daemon_pid_file()
 {
     local cluster=$1
 
-    echo "${TEMPDIR}/rbd-mirror.${cluster}_daemon.pid"
+    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"
+    fi
 }
 
 setup()
@@ -97,16 +114,18 @@ setup()
        TEMPDIR=`mktemp -d`
     fi
 
-    cd ${SRC_DIR}
-    ./mstart.sh ${CLUSTER1} -n
-    ./mstart.sh ${CLUSTER2} -n
+    if [ -z "${RBD_MIRROR_USE_EXISTING_CLUSTER}" ]; then
+        cd ${SRC_DIR}
+        ./mstart.sh ${CLUSTER1} -n
+        ./mstart.sh ${CLUSTER2} -n
 
-    ln -s $(readlink -f run/${CLUSTER1}/ceph.conf) \
-       ${TEMPDIR}/${CLUSTER1}.conf
-    ln -s $(readlink -f run/${CLUSTER2}/ceph.conf) \
-       ${TEMPDIR}/${CLUSTER2}.conf
+        ln -s $(readlink -f run/${CLUSTER1}/ceph.conf) \
+           ${TEMPDIR}/${CLUSTER1}.conf
+        ln -s $(readlink -f run/${CLUSTER2}/ceph.conf) \
+           ${TEMPDIR}/${CLUSTER2}.conf
 
-    cd ${TEMPDIR}
+        cd ${TEMPDIR}
+    fi
 
     ceph --cluster ${CLUSTER1} osd pool create ${POOL} 64 64
     ceph --cluster ${CLUSTER2} osd pool create ${POOL} 64 64
@@ -127,11 +146,14 @@ cleanup()
     stop_mirror "${CLUSTER1}"
     stop_mirror "${CLUSTER2}"
 
-    cd ${SRC_DIR}
-
-    ./mstop.sh ${CLUSTER1}
-    ./mstop.sh ${CLUSTER2}
-
+    if [ -z "${RBD_MIRROR_USE_EXISTING_CLUSTER}" ]; then
+        cd ${SRC_DIR}
+        ./mstop.sh ${CLUSTER1}
+        ./mstop.sh ${CLUSTER2}
+    else
+        ceph --cluster ${CLUSTER1} osd pool rm ${POOL} ${POOL} --yes-i-really-really-mean-it
+        ceph --cluster ${CLUSTER2} osd pool rm ${POOL} ${POOL} --yes-i-really-really-mean-it
+    fi
     rm -Rf ${TEMPDIR}
 }
 
@@ -139,6 +161,8 @@ start_mirror()
 {
     local cluster=$1
 
+    test -n "${RBD_MIRROR_USE_RBD_MIRROR}" && return
+
     rbd-mirror \
        --cluster ${cluster} \
        --pid-file=$(daemon_pid_file "${cluster}") \
@@ -153,6 +177,8 @@ stop_mirror()
 {
     local cluster=$1
 
+    test -n "${RBD_MIRROR_USE_RBD_MIRROR}" && return
+
     local pid
     pid=$(cat $(daemon_pid_file "${cluster}") 2>/dev/null) || :
     if [ -n "${pid}" ]