summaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests
diff options
context:
space:
mode:
authorGeorge Melikov <[email protected]>2017-02-09 02:27:37 +0300
committerBrian Behlendorf <[email protected]>2017-02-08 15:27:37 -0800
commitd834b9ce5ba6be96ce13c31351cf92c89f7762fe (patch)
tree2f0281f8bdd55010801eae8904b043a6004074e1 /tests/zfs-tests
parentd32d25c5c26c8d1e254bc0fcb8a8ae059e95cebc (diff)
Add `wait_freeing` helper function to ZTS
Sometimes the ZTS checks freed space just after `zfs destroy snapshot` and gets an unexpected value because of space being freed asynchronously. For cases like this add a `wait_freeing` function which blocks until the pools `freeing` property drops to zero. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: George Melikov <[email protected]> Closes #5740
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r--tests/zfs-tests/include/libtest.shlib14
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib2
-rwxr-xr-xtests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh2
3 files changed, 18 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 4127d35a8..31b1e1dfc 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -3078,3 +3078,17 @@ function sync_pool #pool
log_must $SLEEP 2
done
}
+
+#
+# Wait for zpool 'freeing' property drops to zero.
+#
+# $1 pool name
+#
+function wait_freeing #pool
+{
+ typeset pool=${1:-$TESTPOOL}
+ while true; do
+ [[ "0" == "$($ZPOOL list -Ho freeing $pool)" ]] && break
+ log_must $SLEEP 1
+ done
+}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
index 44f85e801..f818b754d 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
@@ -92,6 +92,8 @@ function set_n_check_prop
log_mustnot $ZFS set $prop=$expect_value $dataset
[[ -n $prop ]] && cur_value=$(get_prop $prop $dataset)
+
+ wait_freeing
if [[ "$expect_value" != "" && "$cur_value" != "$old_value" ]];
then
diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh
index 3610491b0..b4437a2a8 100755
--- a/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh
+++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh
@@ -88,6 +88,8 @@ while [[ $i -lt $COUNT ]]; do
(( i = i + 1 ))
done
+wait_freeing $TESTPOOL
+
new_size=`get_prop available $TESTPOOL`
typeset -i tolerance=0