svn commit: r292305 - projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set
Alan Somers
asomers at FreeBSD.org
Wed Dec 16 00:22:16 UTC 2015
Author: asomers
Date: Wed Dec 16 00:22:14 2015
New Revision: 292305
URL: https://svnweb.freebsd.org/changeset/base/292305
Log:
Fix the ro_props_001_pos test, which has spuriously failing for a while.
tests/sys/cddl/zfs/tests/cli_root/zfs_set/ro_props_001_pos.ksh:
- This test runs through many different ZFS property settings,
checking that read-only properties can't be changed from the
'zfs set' command. However, the test reported that the 'used'
property changed.
- The root cause is because, when a ZFS command is issued that
changes the pool configuration (e.g. create filesystem or snapshot),
the action gets recorded in the pool history. However, the
history logging is asynchronous, and its syncing can change the
'used' value for the pool dataset.
- When the initial setup is complete, grab the pool history before
continuing. This will force the outstanding history to be synced
to disk before returning.
tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib:
- Clean up set_n_check_prop() while here so it provides better
feedback on error and is easier to understand.
Submitted by: Will
Sponsored by: Spectra Logic Corporation
Modified:
projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/ro_props_001_pos.ksh
projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/ro_props_001_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/ro_props_001_pos.ksh Wed Dec 16 00:21:21 2015 (r292304)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/ro_props_001_pos.ksh Wed Dec 16 00:22:14 2015 (r292305)
@@ -89,6 +89,12 @@ log_onexit cleanup
create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
+# Make sure any history logs have been synced. They're asynchronously
+# pushed to the syncing context, and could influence the value of some
+# properties on $TESTPOOL, like 'used'. Fetching it here forces the sync,
+# per spa_history.c:spa_history_get().
+log_must $ZPOOL history $TESTPOOL
+
typeset -i i=0
typeset -i j=0
typeset cur_value=""
@@ -126,4 +132,4 @@ while (( i < ${#dataset[@]} )); do
(( i += 1 ))
done
-log_pass "Setting uneditable properties should failed. It passed."
+log_pass "Setting uneditable properties fail, as required."
Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib Wed Dec 16 00:21:21 2015 (r292304)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zfs_set/zfs_set_common.kshlib Wed Dec 16 00:22:14 2015 (r292305)
@@ -52,50 +52,33 @@ function set_n_check_prop
typeset dataset=$3
typeset expect_result=${4:-true}
- typeset old_value=""
- typeset cur_value=""
-
- [[ -n $prop ]] && old_value=$(get_prop $prop $dataset)
-
- if [[ $expect_result == true ]]; then
- [[ -z $prop || -z $dataset ]] && \
- log_fail "property or dataset isn't defined."
-
+ typeset old_value=$(get_prop $prop $dataset)
+ if [ "$expect_result" = "true" ]; then
log_must $ZFS set $prop=$expect_value $dataset
- if [[ $expect_value == "gzip-6" ]]; then
- expect_value="gzip"
- fi
-
- [[ -n $prop ]] && cur_value=$(get_prop $prop $dataset)
-
- case $prop in
- reservation|reserv|quota )
- if [[ $expect_value == "none" ]]; then
- [[ $cur_value != "0" ]] && \
- log_fail "The '$dataset' '$prop' value \
- '$cur_value' is not expected."
- elif [[ $cur_value != $expect_value ]]; then
- log_fail "The '$dataset' '$prop' value '$cur_value' \
- does not equal the expected value '$expect_value'."
- fi
- ;;
- * )
- if [[ $cur_value != $expect_value ]]; then
- log_fail "The '$dataset' '$prop' value '$cur_value' \
- does not equal the expected value '$expect_value'."
- fi
- ;;
- esac
-
else
log_mustnot $ZFS set $prop=$expect_value $dataset
+ fi
+ typeset cur_value=$(get_prop $prop $dataset)
- [[ -n $prop ]] && cur_value=$(get_prop $prop $dataset)
-
- if [[ "$expect_value" != "" && "$cur_value" != "$old_value" ]];
- then
- log_fail "The '$dataset' '$prop' value '$cur_value' \
- should equal with '$old_value'."
+ err="ERROR: Dataset '$dataset': '$prop' value '$cur_value'"
+ if [ "$expect_result" = "true" ]; then
+ case "$prop" in
+ reservation|reserv|quota)
+ if [ "$expect_value" = "none" -a "$cur_value" != "0" ]; then
+ err="$err should not be set!"
+ log_fail "$err"
+ return
+ fi
+ ;;
+ esac
+ if [ "$cur_value" != "$expect_value" ]; then
+ err="$err should have changed to '$expect_value'!"
+ log_fail "$err"
+ fi
+ else
+ if [ "$expect_value" != "" -a "$cur_value" != "$old_value" ]; then
+ err="$err should be unchanged at '$old_value'!"
+ log_fail "$err"
fi
fi
}
More information about the svn-src-projects
mailing list