test/lvol: [jq] replace -S with sort()

It seems like -S will sort only keys within given objects, but if
actual objects are in different order, the sorting results may still
differ.

To avoid this, replace -S with jq's sort() which takes entire array,
and all its objects, as an input to be sorted. This should result in
the same output regardless of the initial position of given objects.

Change-Id: I4eca9474f1cea73040ae4a13692a1074fa1c4fc3
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1973
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Michal Berger 2020-04-22 13:27:13 +02:00 committed by Tomasz Zawadzki
parent 693ca39917
commit 0b9b70d0f1

View File

@ -78,11 +78,11 @@ function test_tasting() {
new_lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]')
[ "$(jq length <<< "$new_lvols")" == "10" ]
new_lvs=$(rpc_cmd bdev_lvol_get_lvstores | jq .)
if ! diff <(jq -S . <<<"$old_lvs") <(jq -S . <<<"$new_lvs"); then
if ! diff <(jq '. | sort' <<<"$old_lvs") <(jq '. | sort' <<<"$new_lvs"); then
echo "ERROR: old and loaded lvol store is not the same"
return 1
fi
if ! diff <(jq -S . <<<"$old_lvols") <(jq -S . <<<"$new_lvols"); then
if ! diff <(jq '. | sort' <<<"$old_lvols") <(jq '. | sort' <<<"$new_lvols"); then
echo "ERROR: old and loaded lvols are not the same"
return 1
fi