-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZTS: Add zfs/zpool JSON sanity tests
Run basic JSON validation tests on the new `zfs|zpool -j` output. Signed-off-by: Tony Hutter <[email protected]>
- Loading branch information
1 parent
32edec5
commit 01bd647
Showing
6 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ export SYSTEM_FILES_COMMON='awk | |
hostname | ||
id | ||
iostat | ||
jq | ||
kill | ||
ksh | ||
ldd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/zfs-tests/tests/functional/cli_root/json/cleanup.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 57 additions & 0 deletions
57
tests/zfs-tests/tests/functional/cli_root/json/json_sanity.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |