ZTS: test that zdb can work with libzpool tunables

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #17537
This commit is contained in:
Rob Norris 2025-07-12 15:39:38 +10:00 committed by Brian Behlendorf
parent fce18e04d5
commit 1b84bd1dff
3 changed files with 74 additions and 1 deletions

View File

@ -170,7 +170,8 @@ tests = ['zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', 'zdb_005_pos',
'zdb_block_size_histogram', 'zdb_checksum', 'zdb_decompress',
'zdb_display_block', 'zdb_encrypted', 'zdb_label_checksum',
'zdb_object_range_neg', 'zdb_object_range_pos', 'zdb_objset_id',
'zdb_decompress_zstd', 'zdb_recover', 'zdb_recover_2', 'zdb_backup']
'zdb_decompress_zstd', 'zdb_recover', 'zdb_recover_2', 'zdb_backup',
'zdb_tunables']
pre =
post =
tags = ['functional', 'cli_root', 'zdb']

View File

@ -645,6 +645,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/cli_root/zdb/zdb_objset_id.ksh \
functional/cli_root/zdb/zdb_recover_2.ksh \
functional/cli_root/zdb/zdb_recover.ksh \
functional/cli_root/zdb/zdb_tunables.ksh \
functional/cli_root/zfs_bookmark/cleanup.ksh \
functional/cli_root/zfs_bookmark/setup.ksh \
functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh \

View File

@ -0,0 +1,71 @@
#!/bin/ksh -p
# SPDX-License-Identifier: CDDL-1.0
#
# 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) 2025, Rob Norris <robn@despairlabs.com>
#
. $STF_SUITE/include/libtest.shlib
verify_runnable "both"
log_assert "zdb can work with libzpool tunables"
# a tunable name by itself, or with the "show" command, produces name and value
log_must eval 'zdb -o zfs_recover | grep -qE "^zfs_recover: 0$"'
log_must eval 'zdb -o show=zfs_recover | grep -qE "^zfs_recover: 0$"'
# info about a tunable shows a different format
log_must eval 'zdb -o info=zfs_recover | grep -qE "^zfs_recover \[[[:alnum:]_]+ r[dw]]: .+"'
# "show" by itself shows all the tunables and their values
# this tests limits to 50 tunables, and then counts the number that match
# the format, which should be all of them
log_must test $(zdb -o show | head -50 | grep -cE "^[[:alnum:]_]+: .+") -eq 50
# "info" by itself shows info about all tunables
# like previous test, we limit and then count
log_must test $(zdb -o info | head -50 | grep -cE "^[[:alnum:]_]+ \[[[:alnum:]_]+ r[dw]]: .+") -eq 50
# can't lookup nonexistent tunables
log_mustnot_expect 'no such tunable: hello' zdb -o hello
log_mustnot_expect 'no such tunable: hello' zdb -o show=hello
log_mustnot_expect 'no such tunable: hello' zdb -o info=hello
# setting a tunable shows the old and the new value
log_must eval 'zdb -o zfs_recover=1 | grep -qE "^zfs_recover: 0 -> 1$"'
# replacing a value still sets it
log_must eval 'zdb -o zfs_recover=0 | grep -qE "^zfs_recover: 0 -> 0$"'
# can't set the "magic" commands
log_mustnot_expect 'no such tunable: 0' zdb -o show=0
log_mustnot_expect 'no such tunable: 1' zdb -o info=1
# can set multiple in same command
log_must eval 'zdb -o zfs_recover=1 -o zfs_flags=512 | xargs | grep -qE "^zfs_recover: 0 -> 1 zfs_flags: 4294965758 -> 512$"'
# can set and show in same command
log_must eval 'zdb -o zfs_recover=1 -o zfs_recover -o zfs_recover=0 | xargs | grep -qE "^zfs_recover: 0 -> 1 zfs_recover: 1 zfs_recover: 1 -> 0$"'
log_pass "zdb can work with libzpool tunables"