]> git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_011_pos.ksh
New upstream version 0.7.2
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cli_root / zfs_destroy / zfs_destroy_011_pos.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18 . $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
19 . $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
20
21 ################################################################################
22 #
23 # 'zfs destroy -d <snap>' should mark snapshot for deferred destroy when
24 # there is a user hold.
25 #
26 # 1. Create test environment without clones.
27 # 2. 'zfs hold <tag> <snap>'
28 # 3. 'zfs destroy -d <snap>'
29 # 4. Verify snapshot is marked for deferred destroy.
30 # 5. 'zfs release <tag> <snap>'
31 # 6. Verify that the snapshot is destroyed.
32 #
33 ################################################################################
34
35 function test_snap_run
36 {
37 typeset dstype=$1
38
39 snap=$(eval echo \$${dstype}SNAP)
40 log_must zfs hold zfstest $snap
41 log_must zfs destroy -d $snap
42 log_must datasetexists $snap
43 log_must eval "[[ $(get_prop defer_destroy $snap) == 'on' ]]"
44 log_must zfs release zfstest $snap
45 log_mustnot datasetexists $snap
46 }
47
48 log_assert "'zfs destroy -d <snap>' marks held snapshot for deferred destroy"
49 log_onexit cleanup_testenv
50
51 setup_testenv snap
52
53 for dstype in FS VOL; do
54 if [[ $dstype == VOL ]]; then
55 if is_global_zone; then
56 test_snap_run $dstype
57 fi
58 else
59 test_snap_run $dstype
60 fi
61 done
62
63 log_pass "'zfs destroy -d <snap>' marks held snapshot for deferred destroy"