2019-09-16 19:07:36 +00:00
|
|
|
#!/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
|
2020-02-11 19:15:28 +00:00
|
|
|
CEPH_ARGS='' rbd --cluster ${CLUSTER1} mirror pool peer bootstrap create ${POOL} > ${TOKEN}
|
|
|
|
CEPH_ARGS='' rbd --cluster ${CLUSTER1} mirror pool peer bootstrap create ${PARENT_POOL} > ${TOKEN_2}
|
2019-09-16 19:07:36 +00:00
|
|
|
cmp ${TOKEN} ${TOKEN_2}
|
|
|
|
|
2020-02-11 19:15:28 +00:00
|
|
|
CEPH_ARGS='' rbd --cluster ${CLUSTER2} --pool ${POOL} mirror pool peer bootstrap import ${TOKEN} --direction rx-only
|
|
|
|
CEPH_ARGS='' rbd --cluster ${CLUSTER2} --pool ${PARENT_POOL} mirror pool peer bootstrap import ${TOKEN} --direction rx-tx
|
2019-09-16 19:07:36 +00:00
|
|
|
|
|
|
|
start_mirrors ${CLUSTER1}
|
|
|
|
start_mirrors ${CLUSTER2}
|
|
|
|
|
|
|
|
testlog "TEST: verify rx-only direction"
|
2023-02-10 12:56:57 +00:00
|
|
|
# rx-only peer is added immediately by "rbd mirror pool peer bootstrap import"
|
|
|
|
rbd --cluster ${CLUSTER2} --pool ${POOL} mirror pool info --format json | jq -e '.peers[0].direction == "rx-only"'
|
|
|
|
# tx-only peer is added asynchronously by mirror_peer_ping class method
|
|
|
|
while ! rbd --cluster ${CLUSTER1} --pool ${POOL} mirror pool info --format json | jq -e '.peers | length > 0'; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
rbd --cluster ${CLUSTER1} --pool ${POOL} mirror pool info --format json | jq -e '.peers[0].direction == "tx-only"'
|
2019-09-16 19:07:36 +00:00
|
|
|
|
2021-09-24 10:29:34 +00:00
|
|
|
create_image_and_enable_mirror ${CLUSTER1} ${POOL} image1
|
2019-09-16 19:07:36 +00:00
|
|
|
|
|
|
|
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"
|
2023-02-10 12:56:57 +00:00
|
|
|
# both rx-tx peers are added immediately by "rbd mirror pool peer bootstrap import"
|
|
|
|
rbd --cluster ${CLUSTER1} --pool ${PARENT_POOL} mirror pool info --format json | jq -e '.peers[0].direction == "rx-tx"'
|
|
|
|
rbd --cluster ${CLUSTER2} --pool ${PARENT_POOL} mirror pool info --format json | jq -e '.peers[0].direction == "rx-tx"'
|
|
|
|
|
2019-09-16 19:07:36 +00:00
|
|
|
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
|