]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/workunits/rbd: stress test `rbd mirror pool status --verbose`
authorMykola Golub <mgolub@suse.com>
Wed, 14 Aug 2019 07:40:02 +0000 (08:40 +0100)
committerMykola Golub <mgolub@suse.com>
Fri, 16 Aug 2019 11:50:42 +0000 (12:50 +0100)
Fixes: https://tracker.ceph.com/issues/40923
Signed-off-by: Mykola Golub <mgolub@suse.com>
qa/workunits/rbd/rbd_mirror_helpers.sh

index 7255eb1e4fdd12dda54eb4450dca23e1d1518e28..bb96d6fc3b7a45eebc7e84561abb1b30b66150ae 100755 (executable)
@@ -687,7 +687,7 @@ test_status_in_pool_dir()
     local description_pattern="$5"
     local service_pattern="$6"
 
-    local status_log=${TEMPDIR}/${cluster}-${image}.mirror_status
+    local status_log=${TEMPDIR}/${cluster}-${pool}-${image}.mirror_status
     rbd --cluster ${cluster} -p ${pool} mirror image status ${image} |
        tee ${status_log} >&2
     grep "state: .*${state_pattern}" ${status_log} || return 1
@@ -701,7 +701,38 @@ test_status_in_pool_dir()
         grep "service: " ${status_log} && return 1
     fi
 
+    # recheck using `mirror pool status` command to stress test it.
+
+    local last_update="$(sed -nEe 's/^ *last_update: *(.*) *$/\1/p' ${status_log})"
+    test_mirror_pool_status_verbose \
+        ${cluster} ${pool} ${image} "${state_pattern}" "${last_update}" &&
     return 0
+
+    echo "'mirror pool status' test failed" >&2
+    exit 1
+}
+
+test_mirror_pool_status_verbose()
+{
+    local cluster=$1
+    local pool=$2
+    local image=$3
+    local state_pattern="$4"
+    local prev_last_update="$5"
+
+    local status_log=${TEMPDIR}/${cluster}-${pool}.mirror_status
+
+    rbd --cluster ${cluster} mirror pool status ${pool} --verbose --format xml \
+        > ${status_log}
+
+    local last_update state
+    last_update=$($XMLSTARLET sel -t -v \
+        "//images/image[name='${image}']/last_update" < ${status_log})
+    state=$($XMLSTARLET sel -t -v \
+        "//images/image[name='${image}']/state" < ${status_log})
+
+    echo "${state}" | grep "${state_pattern}" ||
+    test "${last_update}" '>' "${prev_last_update}"
 }
 
 wait_for_status_in_pool_dir()