mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
ZTS: Add zfs/zpool JSON sanity tests
Run basic JSON validation tests on the new `zfs|zpool -j` output. Reviewed-by: Ameer Hamza <ahamza@ixsystems.com> Reviewed-by: Umer Saleem <usaleem@ixsystems.com> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #16217
This commit is contained in:
parent
959e963c81
commit
dab810014e
@ -153,6 +153,10 @@ tests = [ 'clean_mirror_001_pos', 'clean_mirror_002_pos',
|
||||
'clean_mirror_003_pos', 'clean_mirror_004_pos']
|
||||
tags = ['functional', 'clean_mirror']
|
||||
|
||||
[tests/functional/cli_root/json]
|
||||
tests = ['json_sanity']
|
||||
tags = ['functional', 'cli_root', 'json']
|
||||
|
||||
[tests/functional/cli_root/zinject]
|
||||
tests = ['zinject_args']
|
||||
pre =
|
||||
|
@ -46,6 +46,7 @@ export SYSTEM_FILES_COMMON='awk
|
||||
hostname
|
||||
id
|
||||
iostat
|
||||
jq
|
||||
kill
|
||||
ksh
|
||||
ldd
|
||||
|
@ -606,6 +606,9 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/clean_mirror/clean_mirror_004_pos.ksh \
|
||||
functional/clean_mirror/cleanup.ksh \
|
||||
functional/clean_mirror/setup.ksh \
|
||||
functional/cli_root/json/cleanup.ksh \
|
||||
functional/cli_root/json/setup.ksh \
|
||||
functional/cli_root/json/json_sanity.ksh \
|
||||
functional/cli_root/zinject/zinject_args.ksh \
|
||||
functional/cli_root/zdb/zdb_002_pos.ksh \
|
||||
functional/cli_root/zdb/zdb_003_pos.ksh \
|
||||
|
31
tests/zfs-tests/tests/functional/cli_root/json/cleanup.ksh
Executable file
31
tests/zfs-tests/tests/functional/cli_root/json/cleanup.ksh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or https://opensource.org/licenses/CDDL-1.0.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
# Copyright (c) 2024 by Lawrence Livermore National Security, LLC.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
zpool destroy testpool1
|
||||
zpool destroy testpool2
|
||||
|
||||
rm $TESTDIR/file{1..28}
|
||||
rmdir $TESTDIR
|
57
tests/zfs-tests/tests/functional/cli_root/json/json_sanity.ksh
Executable file
57
tests/zfs-tests/tests/functional/cli_root/json/json_sanity.ksh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or https://opensource.org/licenses/CDDL-1.0.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
|
||||
# Copyright (c) 2024 by Lawrence Livermore National Security, LLC.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Basic sanity check for valid JSON from zfs & zpool commands.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Run different zfs/zpool -j commands and check for valid JSON
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
for cmd in "${list[@]}" ; do
|
||||
log_must eval "$cmd | jq > /dev/null"
|
||||
done
|
||||
|
||||
log_pass "zpool and zfs commands outputted valid JSON"
|
50
tests/zfs-tests/tests/functional/cli_root/json/setup.ksh
Executable file
50
tests/zfs-tests/tests/functional/cli_root/json/setup.ksh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or https://opensource.org/licenses/CDDL-1.0.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
# Copyright (c) 2024 by Lawrence Livermore National Security, LLC.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
# Sanity check that 'testpool1' or 'testpool2' don't exist
|
||||
log_mustnot zpool status -j | \
|
||||
jq -e '.pools | has("testpool1") or has("testpool2")' &> /dev/null
|
||||
|
||||
mkdir -p $TESTDIR
|
||||
truncate -s 80M $TESTDIR/file{1..28}
|
||||
|
||||
DISK=${DISKS%% *}
|
||||
|
||||
# Create complex pool configs to exercise JSON
|
||||
zpool create -f testpool1 draid $TESTDIR/file{1..10} \
|
||||
special $DISK \
|
||||
dedup $TESTDIR/file11 \
|
||||
special $TESTDIR/file12 \
|
||||
cache $TESTDIR/file13 \
|
||||
log $TESTDIR/file14
|
||||
|
||||
zpool create -f testpool2 mirror $TESTDIR/file{15,16} \
|
||||
raidz1 $TESTDIR/file{17,18,19} \
|
||||
cache $TESTDIR/file20 \
|
||||
log $TESTDIR/file21 \
|
||||
special mirror $TESTDIR/file{22,23} \
|
||||
dedup mirror $TESTDIR/file{24,25} \
|
||||
spare $TESTDIR/file{26,27,28}
|
Loading…
Reference in New Issue
Block a user