aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create')
-rw-r--r--sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am3
-rw-r--r--sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib81
-rwxr-xr-xsys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_006_pos.ksh58
-rwxr-xr-xsys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_007_pos.ksh54
-rwxr-xr-xsys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_008_pos.ksh54
5 files changed, 250 insertions, 0 deletions
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"