From 3ec68a4414ececbae227a508bcc7e236c358e64c Mon Sep 17 00:00:00 2001 From: cao Date: Fri, 23 Sep 2016 06:28:34 +0800 Subject: [PATCH] Update zfs destroy test scripts Update and enable zfs_destroy_0[08-13]_*.ksh. Reviewed-by: Brian Behlendorf Signed-off-by: cao.xuewen Closes #5068 --- tests/runfiles/linux.run | 12 +++------ .../cli_root/zfs_destroy/cleanup.ksh | 2 -- .../zfs_destroy/zfs_destroy_008_pos.ksh | 17 ++++++++++-- .../zfs_destroy/zfs_destroy_009_pos.ksh | 23 ++++++++++++---- .../zfs_destroy/zfs_destroy_010_pos.ksh | 26 ++++++++++++++----- .../zfs_destroy/zfs_destroy_011_pos.ksh | 23 ++++++++++++---- .../zfs_destroy/zfs_destroy_012_pos.ksh | 23 ++++++++++++---- .../zfs_destroy/zfs_destroy_013_neg.ksh | 23 ++++++++++++---- .../zfs_destroy/zfs_destroy_common.kshlib | 2 +- 9 files changed, 111 insertions(+), 40 deletions(-) diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index 7d55a25a13..7d8f4b51c8 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -96,16 +96,12 @@ tests = ['zfs_create_001_pos', 'zfs_create_002_pos', 'zfs_create_003_pos', # DISABLED: # zfs_destroy_005_neg - busy mountpoint behavior -# zfs_destroy_008_pos - busy mountpoint behavior -# zfs_destroy_009_pos - busy mountpoint behavior -# zfs_destroy_010_pos - busy mountpoint behavior -# zfs_destroy_011_pos - busy mountpoint behavior -# zfs_destroy_012_pos - busy mountpoint behavior -# zfs_destroy_013_neg - busy mountpoint behavior [tests/functional/cli_root/zfs_destroy] tests = ['zfs_destroy_001_pos', 'zfs_destroy_002_pos', 'zfs_destroy_003_pos', - 'zfs_destroy_004_pos', 'zfs_destroy_006_neg', 'zfs_destroy_007_neg', - 'zfs_destroy_014_pos', 'zfs_destroy_015_pos', 'zfs_destroy_016_pos'] + 'zfs_destroy_004_pos','zfs_destroy_006_neg', 'zfs_destroy_007_neg', + 'zfs_destroy_008_pos','zfs_destroy_009_pos', 'zfs_destroy_010_pos', + 'zfs_destroy_011_pos','zfs_destroy_012_pos', 'zfs_destroy_013_neg', + 'zfs_destroy_014_pos','zfs_destroy_015_pos', 'zfs_destroy_016_pos'] # DISABLED: # zfs_get_004_pos - nested pools diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/cleanup.ksh index 90c0ac75f4..e838ba8a59 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/cleanup.ksh @@ -27,6 +27,4 @@ . $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib -cleanup_testenv - default_cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_008_pos.ksh index b9a866a3ff..3efc9c9754 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_008_pos.ksh @@ -38,14 +38,27 @@ # ################################################################################ +function test_s_run +{ + typeset snap=$1 + + log_must $ZFS destroy -d $snap + log_mustnot datasetexists $snap +} + log_assert "'zfs destroy -d ' destroys snapshot if there is no clone" log_onexit cleanup_testenv setup_testenv snap for snap in $FSSNAP $VOLSNAP; do - log_must $ZFS destroy -d $snap - log_mustnot datasetexists $snap + if [[ $snap == $VOLSNAP ]]; then + if is_global_zone; then + test_s_run $snap + fi + else + test_s_run $snap + fi done log_pass "'zfs destroy -d ' destroys snapshot if there is no clone" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_009_pos.ksh index b602a3ec38..510776e6e1 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_009_pos.ksh @@ -41,12 +41,10 @@ # ################################################################################ -log_assert "'zfs destroy -d ' marks cloned snapshot for deferred destroy" -log_onexit cleanup_testenv +function test_c_run +{ + typeset dstype=$1 -setup_testenv clone - -for dstype in FS VOL; do snap=$(eval echo \$${dstype}SNAP) clone=$(eval echo \$${dstype}CLONE) log_must $ZFS destroy -d $snap @@ -55,6 +53,21 @@ for dstype in FS VOL; do log_must $ZFS destroy $clone log_mustnot datasetexists $snap log_mustnot datasetexists $clone +} + +log_assert "'zfs destroy -d ' marks cloned snapshot for deferred destroy" +log_onexit cleanup_testenv + +setup_testenv clone + +for dstype in FS VOL; do + if [[ $dstype == VOL ]]; then + if is_global_zone; then + test_c_run $dstype + fi + else + test_c_run $dstype + fi done log_pass "'zfs destroy -d ' marks cloned snapshot for deferred destroy" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_010_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_010_pos.ksh index 150d0b3ead..77d9ed2f8b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_010_pos.ksh @@ -45,21 +45,33 @@ # ################################################################################ -log_assert "'zfs destroy -R' works on deferred destroyed snapshots" -log_onexit cleanup_testenv +function test_clone_run +{ + typeset dstype=$1 -setup_testenv clone -log_must $UMOUNT -f $TESTDIR1 - -for dstype in FS VOL; do ds=$(eval echo \$${dstype}) snap=$(eval echo \$${dstype}SNAP) clone=$(eval echo \$${dstype}CLONE) log_must $ZFS destroy -d $snap log_must datasetexists $snap - log_must $ZFS destroy -R $ds + log_must $ZFS destroy -R $clone log_mustnot datasetexists $snap log_mustnot datasetexists $clone +} + +log_assert "'zfs destroy -R' works on deferred destroyed snapshots" +log_onexit cleanup_testenv + +setup_testenv clone + +for dstype in FS VOL; do + if [[ $dstype == VOL ]]; then + if is_global_zone; then + test_clone_run $dstype + fi + else + test_clone_run $dstype + fi done log_pass "'zfs destroy -R' works on deferred destroyed snapshots" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_011_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_011_pos.ksh index 6039202ed2..b59fc9bdac 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_011_pos.ksh @@ -32,12 +32,10 @@ # ################################################################################ -log_assert "'zfs destroy -d ' marks held snapshot for deferred destroy" -log_onexit cleanup_testenv +function test_snap_run +{ + typeset dstype=$1 -setup_testenv snap - -for dstype in FS VOL; do snap=$(eval echo \$${dstype}SNAP) log_must $ZFS hold zfstest $snap log_must $ZFS destroy -d $snap @@ -45,6 +43,21 @@ for dstype in FS VOL; do log_must eval "[[ $(get_prop defer_destroy $snap) == 'on' ]]" log_must $ZFS release zfstest $snap log_mustnot datasetexists $snap +} + +log_assert "'zfs destroy -d ' marks held snapshot for deferred destroy" +log_onexit cleanup_testenv + +setup_testenv snap + +for dstype in FS VOL; do + if [[ $dstype == VOL ]]; then + if is_global_zone; then + test_snap_run $dstype + fi + else + test_snap_run $dstype + fi done log_pass "'zfs destroy -d ' marks held snapshot for deferred destroy" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_012_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_012_pos.ksh index 076e905159..d543f124b2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_012_pos.ksh @@ -32,12 +32,10 @@ # ################################################################################ -log_assert "deferred destroyed snapshots remain until last hold is released" -log_onexit cleanup_testenv +function test_snap_run +{ + typeset dstype=$1 -setup_testenv snap - -for dstype in FS VOL; do snap=$(eval echo \$${dstype}SNAP) log_must $ZFS hold zfstest1 $snap log_must $ZFS destroy -d $snap @@ -57,6 +55,21 @@ for dstype in FS VOL; do log_must $ZFS release zfstest2 $snap log_mustnot datasetexists $snap +} + +log_assert "deferred destroyed snapshots remain until last hold is released" +log_onexit cleanup_testenv + +setup_testenv snap + +for dstype in FS VOL; do + if [[ $dstype == VOL ]]; then + if is_global_zone; then + test_snap_run $dstype + fi + else + test_snap_run $dstype + fi done log_pass "deferred destroyed snapshots remain until last hold is released" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_013_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_013_neg.ksh index 198573d421..2a7ee209e1 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_013_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_013_neg.ksh @@ -31,12 +31,10 @@ # ################################################################################ -log_assert "zfs destroy of held snapshots fails" -log_onexit cleanup_testenv +function test_snap_run +{ + typeset dstype=$1 -setup_testenv snap - -for dstype in FS VOL; do snap=$(eval echo \$${dstype}SNAP) log_must $ZFS hold zfstest $snap log_mustnot $ZFS destroy $snap @@ -44,6 +42,21 @@ for dstype in FS VOL; do log_must $ZFS release zfstest $snap log_must $ZFS destroy $snap log_mustnot datasetexists $snap +} + +log_assert "zfs destroy of held snapshots fails" +log_onexit cleanup_testenv + +setup_testenv snap + +for dstype in FS VOL; do + if [[ $dstype == VOL ]]; then + if is_global_zone; then + test_snap_run $dstype + fi + else + test_snap_run $dstype + fi done log_pass "zfs destroy of held snapshots fails" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib index ba3c9d4add..41c1a4b56c 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib @@ -97,7 +97,7 @@ function setup_testenv #[dtst] # function cleanup_testenv { - if is_global_zone && ismounted "$TESTDIR1" "ufs" ; then + if is_global_zone && ismounted "$TESTDIR1" "$NEWFS_DEFAULT_FS" ; then log_must $UMOUNT -f $TESTDIR1 fi if [[ -d $TESTDIR1 ]]; then