From 458babe7ee2e5fc0c4519a94249cbc1bd7cec9b6 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Sun, 15 Apr 2018 21:49:48 -0700 Subject: [PATCH] test: Use jq in a compatible way and for easier diff analysis Signed-off-by: David Zafman --- qa/standalone/scrub/osd-scrub-repair.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/qa/standalone/scrub/osd-scrub-repair.sh b/qa/standalone/scrub/osd-scrub-repair.sh index 9e64993cdac55..da6ec81af4fa3 100755 --- a/qa/standalone/scrub/osd-scrub-repair.sh +++ b/qa/standalone/scrub/osd-scrub-repair.sh @@ -31,16 +31,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)' -- 2.39.5