]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd: stress test `rbd mirror pool status --verbose` 29875/head
authorMykola Golub <mgolub@suse.com>
Wed, 14 Aug 2019 07:40:02 +0000 (08:40 +0100)
committerMykola Golub <mgolub@suse.com>
Mon, 21 Oct 2019 08:15:44 +0000 (11:15 +0300)
Fixes: https://tracker.ceph.com/issues/40923
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 0866a2456b773843537681c768d93d1c9e7718a4)

Conflicts:
qa/workunits/rbd/rbd_mirror_helpers.sh:
          - trivial resolution in test_status_in_pool_dir
          - adding missing XMLSTARLET definition (added in master by 917f8a0)

qa/workunits/rbd/rbd_mirror_helpers.sh

index 0a23b861a98f01e2df06339aff1a2711039aa09b..8270d1ea8cf0cea26b492d6e4df5c30cf4d0d23d 100755 (executable)
 #     ../qa/workunits/rbd/rbd_mirror.sh cleanup
 #
 
+if type xmlstarlet > /dev/null 2>&1; then
+    XMLSTARLET=xmlstarlet
+elif type xml > /dev/null 2>&1; then
+    XMLSTARLET=xml
+else
+    echo "Missing xmlstarlet binary!"
+    exit 1
+fi
+
 CLUSTER1=cluster1
 CLUSTER2=cluster2
 POOL=mirror
@@ -544,11 +553,44 @@ test_status_in_pool_dir()
     local state_pattern=$4
     local description_pattern=$5
 
-    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
     grep "description: .*${description_pattern}" ${status_log} || return 1
+
+    # 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()