mirror of https://github.com/ceph/go-ceph
entrypoint: add --mirror-state option
The --mirror-state option specifies a path to a file in which the script will record the state of (rbd) mirroring. This can then later be reused in order to skip the somewhat time consuming mirroring setup if the statefile indicates mirroring is already functional. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
615b122e49
commit
58289e2547
|
@ -11,13 +11,14 @@ MICRO_OSD_PATH="/micro-osd.sh"
|
||||||
BUILD_TAGS=""
|
BUILD_TAGS=""
|
||||||
RESULTS_DIR=/results
|
RESULTS_DIR=/results
|
||||||
CEPH_CONF=/tmp/ceph/ceph.conf
|
CEPH_CONF=/tmp/ceph/ceph.conf
|
||||||
|
MIRROR_STATE=/dev/null
|
||||||
|
|
||||||
|
|
||||||
# Default env vars that are not currently changed by this script
|
# Default env vars that are not currently changed by this script
|
||||||
# but can be used to change the test behavior:
|
# but can be used to change the test behavior:
|
||||||
# GO_CEPH_TEST_MDS_NAME
|
# GO_CEPH_TEST_MDS_NAME
|
||||||
|
|
||||||
CLI="$(getopt -o h --long test-run:,test-bench:,test-pkg:,pause,cpuprofile,memprofile,no-cover,micro-osd:,wait-for:,results:,ceph-conf:,mirror:,help -n "${0}" -- "$@")"
|
CLI="$(getopt -o h --long test-run:,test-bench:,test-pkg:,pause,cpuprofile,memprofile,no-cover,micro-osd:,wait-for:,results:,ceph-conf:,mirror:,mirror-state:,help -n "${0}" -- "$@")"
|
||||||
eval set -- "${CLI}"
|
eval set -- "${CLI}"
|
||||||
while true ; do
|
while true ; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
|
@ -65,6 +66,11 @@ while true ; do
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--mirror-state)
|
||||||
|
MIRROR_STATE="${2}"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--cpuprofile)
|
--cpuprofile)
|
||||||
CPUPROFILE=yes
|
CPUPROFILE=yes
|
||||||
shift
|
shift
|
||||||
|
@ -87,6 +93,7 @@ while true ; do
|
||||||
echo " --micro-osd Specify path to micro-osd script"
|
echo " --micro-osd Specify path to micro-osd script"
|
||||||
echo " --wait-for=FILES Wait for files before starting tests"
|
echo " --wait-for=FILES Wait for files before starting tests"
|
||||||
echo " (colon separated, disables micro-osd)"
|
echo " (colon separated, disables micro-osd)"
|
||||||
|
echo " --mirror-state=PATH Path to track state of (rbd) mirroring"
|
||||||
echo " --results=PATH Specify path to store test results"
|
echo " --results=PATH Specify path to store test results"
|
||||||
echo " --ceph-conf=PATH Specify path to ceph configuration"
|
echo " --ceph-conf=PATH Specify path to ceph configuration"
|
||||||
echo " --mirror=PATH Specify path to ceph conf of mirror"
|
echo " --mirror=PATH Specify path to ceph conf of mirror"
|
||||||
|
@ -143,6 +150,11 @@ test_failed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_mirroring() {
|
setup_mirroring() {
|
||||||
|
mstate="$(cat "${MIRROR_STATE}" 2>/dev/null || true)"
|
||||||
|
if [[ "$mstate" = functional ]]; then
|
||||||
|
echo "Mirroring already functional"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
echo "Setting up mirroring..."
|
echo "Setting up mirroring..."
|
||||||
local CONF_A=${CEPH_CONF}
|
local CONF_A=${CEPH_CONF}
|
||||||
local CONF_B=${MIRROR_CONF}
|
local CONF_B=${MIRROR_CONF}
|
||||||
|
@ -155,6 +167,7 @@ setup_mirroring() {
|
||||||
rbd -c $CONF_A mirror pool peer bootstrap create --site-name ceph_a rbd > token
|
rbd -c $CONF_A mirror pool peer bootstrap create --site-name ceph_a rbd > token
|
||||||
rbd -c $CONF_B mirror pool peer bootstrap import --site-name ceph_b rbd token
|
rbd -c $CONF_B mirror pool peer bootstrap import --site-name ceph_b rbd token
|
||||||
|
|
||||||
|
echo "enabled" > "${MIRROR_STATE}"
|
||||||
rbd -c $CONF_A rm mirror_test 2>/dev/null || true
|
rbd -c $CONF_A rm mirror_test 2>/dev/null || true
|
||||||
rbd -c $CONF_B rm mirror_test 2>/dev/null || true
|
rbd -c $CONF_B rm mirror_test 2>/dev/null || true
|
||||||
(echo "Mirror Test"; dd if=/dev/zero bs=1 count=500K) | rbd -c $CONF_A import - mirror_test
|
(echo "Mirror Test"; dd if=/dev/zero bs=1 count=500K) | rbd -c $CONF_A import - mirror_test
|
||||||
|
@ -170,6 +183,7 @@ setup_mirroring() {
|
||||||
while ! rbd -c $CONF_B export mirror_test - 2>/dev/null | grep -q "Mirror Test" ; do
|
while ! rbd -c $CONF_B export mirror_test - 2>/dev/null | grep -q "Mirror Test" ; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
echo "functional" > "${MIRROR_STATE}"
|
||||||
echo " mirroring functional!"
|
echo " mirroring functional!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue