]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd: improve deletion propagation test case
authorJason Dillaman <dillaman@redhat.com>
Fri, 10 Jun 2016 01:14:27 +0000 (21:14 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 10 Jun 2016 16:47:31 +0000 (12:47 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit de15b198cd7b5e94016605c8016a5cf38c07c6f6)

qa/workunits/rbd/rbd_mirror.sh

index 92065131af437390e8dc3d95b1dee66cecceb816..cfe99491626b44cc51a3ece37943a269848970ea 100755 (executable)
@@ -445,6 +445,15 @@ create_image()
        --image-feature layering,exclusive-lock,journaling ${image}
 }
 
+remove_image()
+{
+    local cluster=$1
+    local pool=$2
+    local image=$3
+
+    rbd --cluster ${cluster} -p ${pool} rm ${image}
+}
+
 clone_image()
 {
     local cluster=$1
@@ -458,7 +467,7 @@ clone_image()
        ${clone_pool}/${clone_image} --image-feature layering,exclusive-lock,journaling
 }
 
-create_protected_snapshot()
+create_snapshot()
 {
     local cluster=$1
     local pool=$2
@@ -466,9 +475,54 @@ create_protected_snapshot()
     local snap=$4
 
     rbd --cluster ${cluster} -p ${pool} snap create ${image}@${snap}
+}
+
+remove_snapshot()
+{
+    local cluster=$1
+    local pool=$2
+    local image=$3
+    local snap=$4
+
+    rbd --cluster ${cluster} -p ${pool} snap rm ${image}@${snap}
+}
+
+protect_snapshot()
+{
+    local cluster=$1
+    local pool=$2
+    local image=$3
+    local snap=$4
+
     rbd --cluster ${cluster} -p ${pool} snap protect ${image}@${snap}
 }
 
+unprotect_snapshot()
+{
+    local cluster=$1
+    local pool=$2
+    local image=$3
+    local snap=$4
+
+    rbd --cluster ${cluster} -p ${pool} snap unprotect ${image}@${snap}
+}
+
+wait_for_snap_present()
+{
+    local cluster=$1
+    local pool=$2
+    local image=$3
+    local snap_name=$4
+    local s
+
+    for s in 1 2 4 8 8 8 8 8 8 8 8 16 16 16 16 32 32 32 32; do
+       sleep ${s}
+        rbd --cluster ${cluster} -p ${pool} info ${image}@${snap_name} || continue
+        return 0
+    done
+    return 1
+}
+
 write_image()
 {
     local cluster=$1
@@ -701,7 +755,8 @@ parent_image=test_parent
 parent_snap=snap
 create_image ${CLUSTER2} ${PARENT_POOL} ${parent_image}
 write_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} 100
-create_protected_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
+create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
+protect_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
 
 clone_image=test_clone
 clone_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image}
@@ -719,13 +774,48 @@ test_status_in_pool_dir ${CLUSTER1} ${POOL} ${clone_image} 'up+replaying' 'maste
 compare_images ${POOL} ${clone_image}
 
 testlog "TEST: disable mirroring / delete non-primary image"
-test_image_present ${CLUSTER1} ${POOL} ${image} 'present'
+image2=test2
+image3=test3
+image4=test4
+image5=test5
+for i in ${image2} ${image3} ${image4} ${image5}; do
+  create_image ${CLUSTER2} ${POOL} ${i}
+  write_image ${CLUSTER2} ${POOL} ${i} 100
+  create_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
+  create_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
+  if [ "${i}" = "${image4}" ] || [ "${i}" = "${image5}" ]; then
+    protect_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
+    protect_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
+  fi
+  write_image ${CLUSTER2} ${POOL} ${i} 100
+  wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'present'
+  wait_for_snap_present ${CLUSTER1} ${POOL} ${i} 'snap2'
+done
+
 set_pool_mirror_mode ${CLUSTER2} ${POOL} 'image'
-disable_mirror ${CLUSTER2} ${POOL} ${image}
-wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'deleted'
+for i in ${image2} ${image4}; do
+  disable_mirror ${CLUSTER2} ${POOL} ${i}
+done
+
+unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap1'
+unprotect_snapshot ${CLUSTER2} ${POOL} ${image5} 'snap2'
+for i in ${image3} ${image5}; do
+  remove_snapshot ${CLUSTER2} ${POOL} ${i} 'snap1'
+  remove_snapshot ${CLUSTER2} ${POOL} ${i} 'snap2'
+  remove_image ${CLUSTER2} ${POOL} ${i}
+done
+
+for i in ${image2} ${image3} ${image4} ${image5}; do
+  wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'deleted'
+done
+
 set_pool_mirror_mode ${CLUSTER2} ${POOL} 'pool'
-wait_for_image_present ${CLUSTER1} ${POOL} ${image} 'present'
-wait_for_image_replay_started ${CLUSTER1} ${POOL} ${image}
+for i in ${image2} ${image4}; do
+  wait_for_image_present ${CLUSTER1} ${POOL} ${i} 'present'
+  wait_for_snap_present ${CLUSTER1} ${POOL} ${i} 'snap2'
+  wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${i}
+  compare_images ${POOL} ${i}
+done
 
 testlog "TEST: disable mirror while daemon is stopped"
 stop_mirror ${CLUSTER1}