From d85e312ead1da7c35d5ee4fe4be3d6e69a68b572 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Fri, 13 May 2016 16:47:25 +0100 Subject: [PATCH] rbd-mirror: test: added image-deleter test case when mirroring is disabled Signed-off-by: Ricardo Dias --- qa/workunits/rbd/rbd_mirror.sh | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/qa/workunits/rbd/rbd_mirror.sh b/qa/workunits/rbd/rbd_mirror.sh index d65a161ad65..74b8b8f0448 100755 --- a/qa/workunits/rbd/rbd_mirror.sh +++ b/qa/workunits/rbd/rbd_mirror.sh @@ -462,6 +462,58 @@ promote_image() rbd --cluster=${cluster} mirror image promote ${POOL}/${image} } +set_pool_mirror_mode() +{ + local cluster=$1 + local mode=$2 + + rbd --cluster=${cluster} -p ${POOL} mirror pool enable ${mode} +} + +disable_mirror() +{ + local cluster=$1 + local image=$2 + + rbd --cluster=${cluster} mirror image disable ${POOL}/${image} +} + +enable_mirror() +{ + local cluster=$1 + local image=$2 + + rbd --cluster=${cluster} mirror image enable ${POOL}/${image} +} + +test_image_present() +{ + local cluster=$1 + local image=$2 + local test_state=$3 + local current_state=deleted + + rbd --cluster=${cluster} -p ${POOL} ls | grep "^${image}$" && + current_state=present + + test "${test_state}" = "${current_state}" +} + +wait_for_image_present() +{ + local cluster=$1 + local image=$2 + local state=$3 + local s + + # TODO: add a way to force rbd-mirror to update replayers + for s in 1 2 4 8 8 8 8 8 8 8 8 16 16; do + sleep ${s} + test_image_present "${cluster}" "${image}" "${state}" && return 0 + done + return 1 +} + # # Main # @@ -588,4 +640,25 @@ test_status_in_pool_dir ${CLUSTER1} ${image} 'up+replaying' 'master_position' test_status_in_pool_dir ${CLUSTER2} ${image} 'up+stopped' compare_images ${image} +testlog "TEST: disable mirroring / delete non-primary image" +test_image_present ${CLUSTER1} ${image} 'present' +set_pool_mirror_mode ${CLUSTER2} 'image' +disable_mirror ${CLUSTER2} ${image} +wait_for_image_present ${CLUSTER1} ${image} 'deleted' +set_pool_mirror_mode ${CLUSTER2} 'pool' +wait_for_image_present ${CLUSTER1} ${image} 'present' +wait_for_image_replay_started ${CLUSTER1} ${image} + +testlog "TEST: disable mirror while daemon is stopped" +stop_mirror ${CLUSTER1} +stop_mirror ${CLUSTER2} +set_pool_mirror_mode ${CLUSTER2} 'image' +disable_mirror ${CLUSTER2} ${image} +test_image_present ${CLUSTER1} ${image} 'present' +start_mirror ${CLUSTER1} +wait_for_image_present ${CLUSTER1} ${image} 'deleted' +set_pool_mirror_mode ${CLUSTER2} 'pool' +wait_for_image_present ${CLUSTER1} ${image} 'present' +wait_for_image_replay_started ${CLUSTER1} ${image} + echo OK