From 85f98c01c09e766b7ad16c58728add129f40f09d Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 16 Sep 2019 15:07:36 -0400 Subject: [PATCH] qa/suites/rbd: test case for rbd-mirror bootstrap Signed-off-by: Jason Dillaman --- .../rbd-mirror-bootstrap-workunit.yaml | 11 +++++ qa/workunits/rbd/rbd_mirror_bootstrap.sh | 49 +++++++++++++++++++ qa/workunits/rbd/rbd_mirror_helpers.sh | 34 +++++++------ 3 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 qa/suites/rbd/mirror/workloads/rbd-mirror-bootstrap-workunit.yaml create mode 100755 qa/workunits/rbd/rbd_mirror_bootstrap.sh diff --git a/qa/suites/rbd/mirror/workloads/rbd-mirror-bootstrap-workunit.yaml b/qa/suites/rbd/mirror/workloads/rbd-mirror-bootstrap-workunit.yaml new file mode 100644 index 00000000000..585f582913f --- /dev/null +++ b/qa/suites/rbd/mirror/workloads/rbd-mirror-bootstrap-workunit.yaml @@ -0,0 +1,11 @@ +meta: +- desc: run the rbd_mirror_bootstrap.sh workunit to test the rbd-mirror daemon +tasks: +- workunit: + clients: + cluster1.client.mirror: [rbd/rbd_mirror_bootstrap.sh] + env: + # override workunit setting of CEPH_ARGS='--cluster' + CEPH_ARGS: '' + RBD_MIRROR_INSTANCES: '1' + RBD_MIRROR_USE_EXISTING_CLUSTER: '1' diff --git a/qa/workunits/rbd/rbd_mirror_bootstrap.sh b/qa/workunits/rbd/rbd_mirror_bootstrap.sh new file mode 100755 index 00000000000..05352f36bb0 --- /dev/null +++ b/qa/workunits/rbd/rbd_mirror_bootstrap.sh @@ -0,0 +1,49 @@ +#!/bin/sh -ex +# +# rbd_mirror_bootstrap.sh - test peer bootstrap create/import +# + +RBD_MIRROR_MANUAL_PEERS=1 +RBD_MIRROR_INSTANCES=${RBD_MIRROR_INSTANCES:-1} +. $(dirname $0)/rbd_mirror_helpers.sh + +setup + +testlog "TEST: bootstrap cluster2 from cluster1" +# create token on cluster1 and import to cluster2 +TOKEN=${TEMPDIR}/peer-token +TOKEN_2=${TEMPDIR}/peer-token-2 +rbd --cluster ${CLUSTER1} mirror pool peer bootstrap create ${POOL} > ${TOKEN} +rbd --cluster ${CLUSTER1} mirror pool peer bootstrap create ${PARENT_POOL} > ${TOKEN_2} +cmp ${TOKEN} ${TOKEN_2} + +rbd --cluster ${CLUSTER2} --pool ${POOL} mirror pool peer bootstrap import ${TOKEN} --direction rx-only +rbd --cluster ${CLUSTER2} --pool ${PARENT_POOL} mirror pool peer bootstrap import ${TOKEN} --direction rx-tx + +start_mirrors ${CLUSTER1} +start_mirrors ${CLUSTER2} + +testlog "TEST: verify rx-only direction" +[ "$(rbd --cluster ${CLUSTER1} --pool ${POOL} mirror pool info --format xml | + ${XMLSTARLET} sel -t -v '//mirror/peers/peer[1]/uuid')" = "" ] + +create_image ${CLUSTER1} ${POOL} image1 + +wait_for_image_replay_started ${CLUSTER2} ${POOL} image1 +write_image ${CLUSTER1} ${POOL} image1 100 +wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${POOL} image1 + +testlog "TEST: verify rx-tx direction" +create_image ${CLUSTER1} ${PARENT_POOL} image1 +create_image ${CLUSTER2} ${PARENT_POOL} image2 + +enable_mirror ${CLUSTER1} ${PARENT_POOL} image1 +enable_mirror ${CLUSTER2} ${PARENT_POOL} image2 + +wait_for_image_replay_started ${CLUSTER2} ${PARENT_POOL} image1 +write_image ${CLUSTER1} ${PARENT_POOL} image1 100 +wait_for_replay_complete ${CLUSTER2} ${CLUSTER1} ${PARENT_POOL} image1 + +wait_for_image_replay_started ${CLUSTER1} ${PARENT_POOL} image2 +write_image ${CLUSTER2} ${PARENT_POOL} image2 100 +wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${PARENT_POOL} image2 diff --git a/qa/workunits/rbd/rbd_mirror_helpers.sh b/qa/workunits/rbd/rbd_mirror_helpers.sh index 97be4535108..027c8af91ed 100755 --- a/qa/workunits/rbd/rbd_mirror_helpers.sh +++ b/qa/workunits/rbd/rbd_mirror_helpers.sh @@ -268,26 +268,28 @@ setup_pools() rbd --cluster ${cluster} mirror pool enable ${POOL}/ns1 pool rbd --cluster ${cluster} mirror pool enable ${POOL}/ns2 image - if [ -z ${RBD_MIRROR_CONFIG_KEY} ]; then - rbd --cluster ${cluster} mirror pool peer add ${POOL} ${remote_cluster} - rbd --cluster ${cluster} mirror pool peer add ${PARENT_POOL} ${remote_cluster} - else - mon_map_file=${TEMPDIR}/${remote_cluster}.monmap - ceph --cluster ${remote_cluster} mon getmap > ${mon_map_file} - mon_addr=$(monmaptool --print ${mon_map_file} | grep -E 'mon\.' | - head -n 1 | sed -E 's/^[0-9]+: ([^ ]+).+$/\1/' | sed -E 's/\/[0-9]+//g') + if [ -z ${RBD_MIRROR_MANUAL_PEERS} ]; then + if [ -z ${RBD_MIRROR_CONFIG_KEY} ]; then + rbd --cluster ${cluster} mirror pool peer add ${POOL} ${remote_cluster} + rbd --cluster ${cluster} mirror pool peer add ${PARENT_POOL} ${remote_cluster} + else + mon_map_file=${TEMPDIR}/${remote_cluster}.monmap + ceph --cluster ${remote_cluster} mon getmap > ${mon_map_file} + mon_addr=$(monmaptool --print ${mon_map_file} | grep -E 'mon\.' | + head -n 1 | sed -E 's/^[0-9]+: ([^ ]+).+$/\1/' | sed -E 's/\/[0-9]+//g') - admin_key_file=${TEMPDIR}/${remote_cluster}.client.${CEPH_ID}.key - CEPH_ARGS='' ceph --cluster ${remote_cluster} auth get-key client.${CEPH_ID} > ${admin_key_file} + admin_key_file=${TEMPDIR}/${remote_cluster}.client.${CEPH_ID}.key + CEPH_ARGS='' ceph --cluster ${remote_cluster} auth get-key client.${CEPH_ID} > ${admin_key_file} - rbd --cluster ${cluster} mirror pool peer add ${POOL} client.${CEPH_ID}@${remote_cluster}-DNE \ - --remote-mon-host "${mon_addr}" --remote-key-file ${admin_key_file} + rbd --cluster ${cluster} mirror pool peer add ${POOL} client.${CEPH_ID}@${remote_cluster}-DNE \ + --remote-mon-host "${mon_addr}" --remote-key-file ${admin_key_file} - uuid=$(rbd --cluster ${cluster} mirror pool peer add ${PARENT_POOL} client.${CEPH_ID}@${remote_cluster}-DNE) - rbd --cluster ${cluster} mirror pool peer set ${PARENT_POOL} ${uuid} mon-host ${mon_addr} - rbd --cluster ${cluster} mirror pool peer set ${PARENT_POOL} ${uuid} key-file ${admin_key_file} + uuid=$(rbd --cluster ${cluster} mirror pool peer add ${PARENT_POOL} client.${CEPH_ID}@${remote_cluster}-DNE) + rbd --cluster ${cluster} mirror pool peer set ${PARENT_POOL} ${uuid} mon-host ${mon_addr} + rbd --cluster ${cluster} mirror pool peer set ${PARENT_POOL} ${uuid} key-file ${admin_key_file} - PEER_CLUSTER_SUFFIX=-DNE + PEER_CLUSTER_SUFFIX=-DNE + fi fi }