]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: test: added image-deleter test case when mirroring is disabled
authorRicardo Dias <rdias@suse.com>
Fri, 13 May 2016 15:47:25 +0000 (16:47 +0100)
committerJason Dillaman <dillaman@redhat.com>
Sun, 22 May 2016 20:13:21 +0000 (16:13 -0400)
Signed-off-by: Ricardo Dias <rdias@suse.com>
qa/workunits/rbd/rbd_mirror.sh

index d65a161ad65786e77da4316cc6f0b6e1466ad0af..74b8b8f04485bdfa27343cbe10830aabe8c2b7e7 100755 (executable)
@@ -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