From: David Zafman Date: Mon, 16 Apr 2018 04:49:48 +0000 (-0700) Subject: test: Use jq in a compatible way and for easier diff analysis X-Git-Tag: v12.2.5~11^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8ec0c73536c8bb4b70a7beaee35b26c7d458d7f;p=ceph.git test: Use jq in a compatible way and for easier diff analysis Signed-off-by: David Zafman (cherry picked from commit 458babe7ee2e5fc0c4519a94249cbc1bd7cec9b6) --- diff --git a/qa/standalone/scrub/osd-scrub-repair.sh b/qa/standalone/scrub/osd-scrub-repair.sh index 7ef39c639588..ecc955063b63 100755 --- a/qa/standalone/scrub/osd-scrub-repair.sh +++ b/qa/standalone/scrub/osd-scrub-repair.sh @@ -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)'