mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
zpool/zfs: allow --json wherever -j is allowed
Mostly so that with the JSON formatting options are also used, they all look the same. To my eye, `-j --json-flat-vdevs` suggests that they are different or unrelated, while `--json --json-flat-vdevs` invites no further questions. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Umer Saleem <usaleem@ixsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Closes #16632
This commit is contained in:
committed by
Brian Behlendorf
parent
26ecd8b993
commit
666903610d
@@ -30,28 +30,39 @@
|
||||
# STRATEGY:
|
||||
# 1. Run different zfs/zpool -j commands and check for valid JSON
|
||||
|
||||
#
|
||||
# -j and --json mean the same thing. Each command will be run twice, replacing
|
||||
# JSONFLAG with the flag under test.
|
||||
list=(
|
||||
"zpool status -j -g --json-int --json-flat-vdevs --json-pool-key-guid"
|
||||
"zpool status -p -j -g --json-int --json-flat-vdevs --json-pool-key-guid"
|
||||
"zpool status -j -c upath"
|
||||
"zpool status -j"
|
||||
"zpool status -j testpool1"
|
||||
"zpool list -j"
|
||||
"zpool list -j -g"
|
||||
"zpool list -j -o fragmentation"
|
||||
"zpool get -j size"
|
||||
"zpool get -j all"
|
||||
"zpool version -j"
|
||||
"zfs list -j"
|
||||
"zfs list -j testpool1"
|
||||
"zfs get -j all"
|
||||
"zfs get -j available"
|
||||
"zfs mount -j"
|
||||
"zfs version -j"
|
||||
"zpool status JSONFLAG -g --json-int --json-flat-vdevs --json-pool-key-guid"
|
||||
"zpool status -p JSONFLAG -g --json-int --json-flat-vdevs --json-pool-key-guid"
|
||||
"zpool status JSONFLAG -c upath"
|
||||
"zpool status JSONFLAG"
|
||||
"zpool status JSONFLAG testpool1"
|
||||
"zpool list JSONFLAG"
|
||||
"zpool list JSONFLAG -g"
|
||||
"zpool list JSONFLAG -o fragmentation"
|
||||
"zpool get JSONFLAG size"
|
||||
"zpool get JSONFLAG all"
|
||||
"zpool version JSONFLAG"
|
||||
"zfs list JSONFLAG"
|
||||
"zfs list JSONFLAG testpool1"
|
||||
"zfs get JSONFLAG all"
|
||||
"zfs get JSONFLAG available"
|
||||
"zfs mount JSONFLAG"
|
||||
"zfs version JSONFLAG"
|
||||
)
|
||||
|
||||
for cmd in "${list[@]}" ; do
|
||||
log_must eval "$cmd | jq > /dev/null"
|
||||
done
|
||||
function run_json_tests
|
||||
{
|
||||
typeset flag=$1
|
||||
for cmd in "${list[@]}" ; do
|
||||
cmd=${cmd//JSONFLAG/$flag}
|
||||
log_must eval "$cmd | jq > /dev/null"
|
||||
done
|
||||
}
|
||||
|
||||
log_must run_json_tests -j
|
||||
log_must run_json_tests --json
|
||||
|
||||
log_pass "zpool and zfs commands outputted valid JSON"
|
||||
|
||||
Reference in New Issue
Block a user