]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: rbd-mirror: compare positions using all fields 8172/head
authorMykola Golub <mgolub@mirantis.com>
Wed, 16 Mar 2016 21:07:07 +0000 (23:07 +0200)
committerMykola Golub <mgolub@mirantis.com>
Wed, 16 Mar 2016 21:07:07 +0000 (23:07 +0200)
Comparing by only entry_tid may give false positives.

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
qa/workunits/rbd/rbd_mirror.sh
qa/workunits/rbd/rbd_mirror_image_replay.sh

index b84fd241b6ccc400993b1246811764ce2bab865b..b8bc942ca60431b0bea0fdd4dba44bf728aa439c 100755 (executable)
@@ -216,21 +216,14 @@ get_position()
     local image=$1
     local id_regexp=$2
 
-    # Parse line like below, looking for the first entry_tid
+    # Parse line like below, looking for the first position
     # [id=, commit_position=[positions=[[object_number=1, tag_tid=3, entry_tid=9], [object_number=0, tag_tid=3, entry_tid=8], [object_number=3, tag_tid=3, entry_tid=7], [object_number=2, tag_tid=3, entry_tid=6]]]]
 
     local status_log=${TEMPDIR}/${RMT_CLUSTER}-${POOL}-${image}.status
     rbd --cluster ${RMT_CLUSTER} -p ${POOL} journal status --image ${image} |
        tee ${status_log} >&2
-    sed -Ee 's/[][,]/ /g' ${status_log} |
-       awk '$1 ~ /id='"${id_regexp}"'$/ {
-               for (i = 1; i < NF; i++) {
-                 if ($i ~ /entry_tid=/) {
-                   print $i;
-                   exit
-                 }
-               }
-             }'
+    sed -nEe 's/^.*\[id='"${id_regexp}"',.*positions=\[\[([^]]*)\],.*$/\1/p' \
+       ${status_log}
 }
 
 get_master_position()
index e5c701391bfcad1f40f22c82882878326e777149..b9ddaf71a725be2f98a50e893b9e87333fc8d261 100755 (executable)
@@ -110,20 +110,13 @@ get_position()
 {
     local id=$1
 
-    # Parse line like below, looking for the first entry_tid
+    # Parse line like below, looking for the first position
     # [id=, commit_position=[positions=[[object_number=1, tag_tid=3, entry_tid=9], [object_number=0, tag_tid=3, entry_tid=8], [object_number=3, tag_tid=3, entry_tid=7], [object_number=2, tag_tid=3, entry_tid=6]]]]
 
     local status_log=${TEMPDIR}/${RMT_POOL}-${IMAGE}.status
     rbd -p ${RMT_POOL} journal status --image ${IMAGE} | tee ${status_log} >&2
-    sed -Ee 's/[][,]/ /g' ${status_log} |
-       awk '$1 == "id='${id}'" {
-               for (i = 1; i < NF; i++) {
-                 if ($i ~ /entry_tid=/) {
-                   print $i;
-                   exit
-                 }
-               }
-             }'
+    sed -nEe 's/^.*\[id='"${id}"',.*positions=\[\[([^]]*)\],.*$/\1/p' \
+       ${status_log}
 }
 
 get_master_position()