]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: Use jq in a compatible way and for easier diff analysis
authorDavid Zafman <dzafman@redhat.com>
Mon, 16 Apr 2018 04:49:48 +0000 (21:49 -0700)
committerDavid Zafman <dzafman@redhat.com>
Mon, 16 Apr 2018 15:23:22 +0000 (08:23 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 458babe7ee2e5fc0c4519a94249cbc1bd7cec9b6)

qa/standalone/scrub/osd-scrub-repair.sh

index 7ef39c6395883d46289221bbf89057ef758fe5ac..ecc955063b63b36f07f45d77677fa35b554bf12d 100755 (executable)
@@ -30,16 +30,19 @@ fi
 getjson="no"
 
 # Filter out mtime and local_mtime dates, version, prior_version and last_reqid (client) from any object_info.
-jqfilter='(. | (.inconsistents[].selected_object_info | .mtime ) |= "----Stripped-----")
-        | (. | (.inconsistents[].selected_object_info | .local_mtime ) |= "----Stripped-----" )
-        | (. | (.inconsistents[].selected_object_info | .last_reqid ) |= "----Stripped-----")
-        | (. | (.inconsistents[].selected_object_info | .version ) |= "----Stripped-----" )
-        | (. | (.inconsistents[].selected_object_info | .prior_version ) |= "----Stripped-----" )
-        | ( . | (.inconsistents[].shards[].object_info | .mtime ) |= "----Stripped-----" )
-        | ( . | (.inconsistents[].shards[].object_info | .local_mtime ) |= "----Stripped-----" )
-        | ( . | (.inconsistents[].shards[].object_info | .last_reqid ) |= "----Stripped-----" )
-        | ( .| (.inconsistents[].shards[].object_info | .version ) |= "----Stripped-----" )
-        | ( .| (.inconsistents[].shards[].object_info | .prior_version ) |= "----Stripped-----" )'
+jqfilter='def walk(f):
+  . as $in
+  | if type == "object" then
+      reduce keys[] as $key
+        ( {}; . + { ($key):  ($in[$key] | walk(f)) } ) | f
+    elif type == "array" then map( walk(f) ) | f
+    else f
+    end;
+walk(if type == "object" then del(.mtime) else . end)
+| walk(if type == "object" then del(.local_mtime) else . end)
+| walk(if type == "object" then del(.last_reqid) else . end)
+| walk(if type == "object" then del(.version) else . end)
+| walk(if type == "object" then del(.prior_version) else . end)'
 
 sortkeys='import json; import sys ; JSON=sys.stdin.read() ; ud = json.loads(JSON) ; print json.dumps(ud, sort_keys=True, indent=2)'