diff options
Diffstat (limited to 'sys/contrib/openzfs/tests')
13 files changed, 393 insertions, 9 deletions
diff --git a/sys/contrib/openzfs/tests/runfiles/common.run b/sys/contrib/openzfs/tests/runfiles/common.run index 11960629e39e..9468ee06de44 100644 --- a/sys/contrib/openzfs/tests/runfiles/common.run +++ b/sys/contrib/openzfs/tests/runfiles/common.run @@ -344,7 +344,8 @@ tests = ['zpool_create_001_pos', 'zpool_create_002_pos', 'zpool_create_draid_003_pos', 'zpool_create_draid_004_pos', 'zpool_create_features_001_pos', 'zpool_create_features_002_pos', 'zpool_create_features_003_pos', 'zpool_create_features_004_neg', - 'zpool_create_features_005_pos', + 'zpool_create_features_005_pos', 'zpool_create_features_006_pos', + 'zpool_create_features_007_pos', 'zpool_create_features_008_pos', 'create-o_ashift', 'zpool_create_tempname', 'zpool_create_dryrun_output'] tags = ['functional', 'cli_root', 'zpool_create'] @@ -468,7 +469,8 @@ tests = ['zpool_split_cliargs', 'zpool_split_devices', tags = ['functional', 'cli_root', 'zpool_split'] [tests/functional/cli_root/zpool_status] -tests = ['zpool_status_001_pos', 'zpool_status_002_pos'] +tests = ['zpool_status_001_pos', 'zpool_status_002_pos', + 'zpool_status_features_001_pos'] tags = ['functional', 'cli_root', 'zpool_status'] [tests/functional/cli_root/zpool_sync] @@ -491,7 +493,7 @@ tests = ['zpool_upgrade_001_pos', 'zpool_upgrade_002_pos', 'zpool_upgrade_003_pos', 'zpool_upgrade_004_pos', 'zpool_upgrade_005_neg', 'zpool_upgrade_006_neg', 'zpool_upgrade_007_pos', 'zpool_upgrade_008_pos', - 'zpool_upgrade_009_neg'] + 'zpool_upgrade_009_neg', 'zpool_upgrade_features_001_pos'] tags = ['functional', 'cli_root', 'zpool_upgrade'] [tests/functional/cli_root/zpool_wait] diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/xattrtest.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/xattrtest.c index 42c510ed082d..8c4cb88955ea 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/xattrtest.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/xattrtest.c @@ -44,11 +44,9 @@ #include <sys/time.h> #include <linux/limits.h> -extern char *program_invocation_short_name; - #define ERROR(fmt, ...) \ - fprintf(stderr, "%s: %s:%d: %s: " fmt "\n", \ - program_invocation_short_name, __FILE__, __LINE__, \ + fprintf(stderr, "xattrtest: %s:%d: %s: " fmt "\n", \ + __FILE__, __LINE__, \ __func__, ## __VA_ARGS__); static const char shortopts[] = "hvycdn:f:x:s:p:t:e:rRko:"; diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in b/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in index 8ec0b96e25d2..1a9cc5a2bb62 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in +++ b/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in @@ -37,6 +37,7 @@ export ZEDLET_ETC_DIR=${ZEDLET_ETC_DIR:-@sysconfdir@/zfs/zed.d} export ZEDLET_LIBEXEC_DIR=${ZEDLET_LIBEXEC_DIR:-@zfsexecdir@/zed.d} export ZPOOL_SCRIPT_DIR=${ZPOOL_SCRIPT_DIR:-@sysconfdir@/zfs/zpool.d} +export ZPOOL_COMPAT_DIR=${ZPOOL_COMPAT_DIR:-@datadir@/zfs/compatibility.d} # Define run length constants export RT_LONG="3" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am index ea0cc49b0945..5e9e83f0db91 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am @@ -36,6 +36,9 @@ dist_pkgdata_SCRIPTS = \ zpool_create_features_003_pos.ksh \ zpool_create_features_004_neg.ksh \ zpool_create_features_005_pos.ksh \ + zpool_create_features_006_pos.ksh \ + zpool_create_features_007_pos.ksh \ + zpool_create_features_008_pos.ksh \ create-o_ashift.ksh \ zpool_create_tempname.ksh \ zpool_create_dryrun_output.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib index 325f0b0360c3..c98e49518712 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib @@ -107,3 +107,84 @@ function save_dump_dev fi echo $dumpdev } + +# +# Verify a pools enabled features match the provided feature set. +# $1, pool name +# $2, feature set(s) +# +# check_feature_set $TESTPOOL set1 set2 set3 ... +# +function check_feature_set +{ + typeset pool=$1 + typeset feature_set=$2 + shift + + for set in "$@"; do + if test -e "$ZPOOL_COMPAT_DIR/$set"; then + file="$ZPOOL_COMPAT_DIR/$set" + else + log_fail "Missing feature file: $ZPOOL_COMPAT_DIR/$set" + fi + done + + # + # Create a temporary file which contains all features which are + # common to the listed feature sets. This is used for comparison + # below to determine which features should be enabled. + # + typeset tmpfile=$(mktemp) + + while read line; do + typeset flag=1 + + if [[ "$line" == "#*" ]]; then + continue + fi + + for set in "$@"; do + if ! grep -q "$line" $ZPOOL_COMPAT_DIR/$set; then + flag=0 + break; + fi + done + + if [[ $flag -eq 1 ]]; then + echo "$line" >>$tmpfile + fi + done <"$file" + + # + # Verify every enabled feature appears in the merged feature set. + # Verify every disabled feature does not. + # + for feature in $(zpool get all $pool | \ + awk '$2 ~ /feature@/ { print $2 }'); do + state=$(get_pool_prop $feature $pool) + name=$(cut -d'@' -f2 <<<"$feature") + + if [[ "$state" = "enabled" || "$state" = "active" ]]; then + if ! grep -q $name $tmpfile; then + cat $tmpfile + rm -f $tmpfile + log_fail "Enabled feature $name not " \ + "in feature set file" + fi + elif [[ "$state" = "disabled" ]]; then + if grep -q $name $tmpfile; then + cat $tmpfile + rm -f $tmpfile + log_fail "Disabled feature $name is " \ + "in feature set file" + fi + else + rm -f $tmpfile + log_fail "Feature $name in unknown state $state" + fi + done + + log_note "Checked all features" + + rm -f $tmpfile +} diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_006_pos.ksh new file mode 100755 index 000000000000..fe98434d1bb6 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_006_pos.ksh @@ -0,0 +1,58 @@ +#!/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 http://www.opensolaris.org/os/licensing. +# 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) 2021 Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify '-o compatibility' reserved values 'off, legacy' +# +# STRATEGY: +# 1. Create a pool with '-o compatibility=off' +# 2. Create a pool with '-o compatibility=legacy' +# 3. Cannot create a pool with '-o compatibility=unknown' +# + +verify_runnable "global" + +function cleanup +{ + datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL +} + +log_onexit cleanup + +log_assert "verify '-o compatibility' reserved values 'off, legacy'" + +log_must zpool create -f -o compatibility=off $TESTPOOL $DISKS +log_must zpool destroy -f $TESTPOOL + +log_must zpool create -f -o compatibility=legacy $TESTPOOL $DISKS +log_must zpool destroy -f $TESTPOOL + +log_mustnot zpool create -f -o compatibility=unknown $TESTPOOL $DISKS + +log_pass "verify '-o compatibility' reserved values 'off, legacy'" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_007_pos.ksh new file mode 100755 index 000000000000..8c812911b3b3 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_007_pos.ksh @@ -0,0 +1,54 @@ +#!/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 http://www.opensolaris.org/os/licensing. +# 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) 2021 Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib + +# +# DESCRIPTION: +# Verify pools can be created with the expected feature set enabled. +# +# STRATEGY: +# 1. Create a pool with a known feature set. +# 2. Verify only those features are active/enabled. +# + +verify_runnable "global" + +function cleanup +{ + datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL +} + +log_onexit cleanup + +log_assert "creates a pool with a specified feature set enabled" + +log_must zpool create -f -o compatibility=compat-2020 $TESTPOOL $DISKS +check_feature_set $TESTPOOL compat-2020 +log_must zpool destroy -f $TESTPOOL + +log_pass "creates a pool with a specified feature set enabled" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_008_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_008_pos.ksh new file mode 100755 index 000000000000..0580d444e724 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_008_pos.ksh @@ -0,0 +1,54 @@ +#!/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 http://www.opensolaris.org/os/licensing. +# 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) 2021 Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib + +# +# DESCRIPTION: +# Verify pools can be created with multiple feature sets. +# +# STRATEGY: +# 1. Create a pool with multiple feature sets. +# 2. Verify only the features common to both sets are enabled. +# + +verify_runnable "global" + +function cleanup +{ + datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL +} + +log_onexit cleanup + +log_assert "creates a pool with multiple feature sets enabled" + +log_must zpool create -f -o compatibility=freebsd-11.0,zol-0.8 $TESTPOOL $DISKS +check_feature_set $TESTPOOL freebsd-11.0 zol-0.8 +log_must zpool destroy -f $TESTPOOL + +log_pass "creates a pool with multiple feature sets enabled" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg index 3c536ca12eac..6075e1f1abbd 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg @@ -57,6 +57,7 @@ typeset -a properties=( "leaked" "multihost" "autotrim" + "compatibility" "feature@async_destroy" "feature@empty_bpobj" "feature@lz4_compress" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am index beb59e3d066b..5553061c67b3 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am @@ -3,4 +3,5 @@ dist_pkgdata_SCRIPTS = \ setup.ksh \ cleanup.ksh \ zpool_status_001_pos.ksh \ - zpool_status_002_pos.ksh + zpool_status_002_pos.ksh \ + zpool_status_features_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_features_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_features_001_pos.ksh new file mode 100755 index 000000000000..635125fc0d1e --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_features_001_pos.ksh @@ -0,0 +1,63 @@ +#!/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 http://www.opensolaris.org/os/licensing. +# 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) 2021 Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib + +# +# DESCRIPTION: +# Verify zpool status only recommends upgrading the pool when +# the enabled features don't match those in the feature set. +# +# STRATEGY: +# 1. Create a pool with a known feature set. +# 2. Verify there is no `zpool status` notice to upgrade the pool. +# 3. Set the pool compatibility to a newer feature set. +# 4. Verify there is a `zpool status` notice to upgrade the pool. +# + +verify_runnable "global" + +function cleanup +{ + datasetexists $TESTPOOL1 && log_must zpool destroy $TESTPOOL1 + rm -f $FILEDEV +} + +FILEDEV="$TEST_BASE_DIR/filedev.$$" + +log_onexit cleanup + +log_assert "check 'zpool status' upgrade notice" + +log_must truncate -s $MINVDEVSIZE $FILEDEV +log_must zpool create -f -o compatibility=compat-2018 $TESTPOOL1 $FILEDEV +log_mustnot check_pool_status $TESTPOOL1 "status" "features are not enabled" + +log_must zpool set compatibility=compat-2020 $TESTPOOL1 +log_must check_pool_status $TESTPOOL1 "status" "features are not enabled" + +log_pass "check 'zpool status' upgrade notice" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile.am index 18311ed2ca25..c7f321a2f61d 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile.am +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile.am @@ -12,7 +12,8 @@ dist_pkgdata_SCRIPTS = \ zpool_upgrade_006_neg.ksh \ zpool_upgrade_007_pos.ksh \ zpool_upgrade_008_pos.ksh \ - zpool_upgrade_009_neg.ksh + zpool_upgrade_009_neg.ksh \ + zpool_upgrade_features_001_pos.ksh dist_pkgdata_DATA = \ zpool_upgrade.cfg \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_features_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_features_001_pos.ksh new file mode 100755 index 000000000000..5170d31b46da --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_features_001_pos.ksh @@ -0,0 +1,67 @@ +#!/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 http://www.opensolaris.org/os/licensing. +# 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) 2021 Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib + +# +# DESCRIPTION: +# Verify pools can be upgraded to known feature sets. +# +# STRATEGY: +# 1. Create a pool with a known feature set. +# 2. Verify only those features are active/enabled. +# 3. Upgrade the pool to a newer feature set. +# 4. Verify only those features are active/enabled. +# + +verify_runnable "global" + +function cleanup +{ + datasetexists $TESTPOOL1 && log_must zpool destroy $TESTPOOL1 + rm -f $FILEDEV +} + +FILEDEV="$TEST_BASE_DIR/filedev.$$" + +log_onexit cleanup + +log_assert "verify pools can be upgraded to known feature sets." + +log_must truncate -s $MINVDEVSIZE $FILEDEV +log_must zpool create -f -o compatibility=compat-2018 $TESTPOOL1 $FILEDEV +check_feature_set $TESTPOOL1 compat-2018 +log_mustnot check_pool_status $TESTPOOL1 "status" "features are not enabled" + +log_must zpool set compatibility=compat-2020 $TESTPOOL1 +log_must check_pool_status $TESTPOOL1 "status" "features are not enabled" + +log_must zpool upgrade $TESTPOOL1 +check_feature_set $TESTPOOL1 compat-2020 +log_mustnot check_pool_status $TESTPOOL1 "status" "features are not enabled" + +log_pass "verify pools can be upgraded to known feature sets." |