1d583b39bSJohn Wren Kennedy#!/bin/ksh -p
2d583b39bSJohn Wren Kennedy#
3d583b39bSJohn Wren Kennedy# This file and its contents are supplied under the terms of the
4d583b39bSJohn Wren Kennedy# Common Development and Distribution License ("CDDL"), version 1.0.
5d583b39bSJohn Wren Kennedy# You may only use this file in accordance with the terms of version
6d583b39bSJohn Wren Kennedy# 1.0 of the CDDL.
7d583b39bSJohn Wren Kennedy#
8d583b39bSJohn Wren Kennedy# A full copy of the text of the CDDL should have accompanied this
9d583b39bSJohn Wren Kennedy# source.  A copy of the CDDL is also available via the Internet at
10d583b39bSJohn Wren Kennedy# http://www.illumos.org/license/CDDL.
11d583b39bSJohn Wren Kennedy#
12d583b39bSJohn Wren Kennedy
13d583b39bSJohn Wren Kennedy#
14*1d32ba66SJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
15d583b39bSJohn Wren Kennedy#
16d583b39bSJohn Wren Kennedy
17d583b39bSJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib
18d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
19d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
20d583b39bSJohn Wren Kennedy
21d583b39bSJohn Wren Kennedy################################################################################
22d583b39bSJohn Wren Kennedy#
23d583b39bSJohn Wren Kennedy# 'zfs destroy -d <snap>' should mark snapshot for deferred destroy when
24d583b39bSJohn Wren Kennedy# there is a user hold.
25d583b39bSJohn Wren Kennedy#
26d583b39bSJohn Wren Kennedy# 1. Create test environment without clones.
27d583b39bSJohn Wren Kennedy# 2. 'zfs hold <tag> <snap>'
28d583b39bSJohn Wren Kennedy# 3. 'zfs destroy -d <snap>'
29d583b39bSJohn Wren Kennedy# 4. Verify snapshot is marked for deferred destroy.
30d583b39bSJohn Wren Kennedy# 5. 'zfs release <tag> <snap>'
31d583b39bSJohn Wren Kennedy# 6. Verify that the snapshot is destroyed.
32d583b39bSJohn Wren Kennedy#
33d583b39bSJohn Wren Kennedy################################################################################
34d583b39bSJohn Wren Kennedy
35d583b39bSJohn Wren Kennedylog_assert "'zfs destroy -d <snap>' marks held snapshot for deferred destroy"
36d583b39bSJohn Wren Kennedylog_onexit cleanup_testenv
37d583b39bSJohn Wren Kennedy
38d583b39bSJohn Wren Kennedysetup_testenv snap
39d583b39bSJohn Wren Kennedy
40d583b39bSJohn Wren Kennedyfor dstype in FS VOL; do
41d583b39bSJohn Wren Kennedy    snap=$(eval echo \$${dstype}SNAP)
42*1d32ba66SJohn Wren Kennedy    log_must zfs hold zfstest $snap
43*1d32ba66SJohn Wren Kennedy    log_must zfs destroy -d $snap
44d583b39bSJohn Wren Kennedy    log_must datasetexists $snap
45d583b39bSJohn Wren Kennedy    log_must eval "[[ $(get_prop defer_destroy $snap) == 'on' ]]"
46*1d32ba66SJohn Wren Kennedy    log_must zfs release zfstest $snap
47d583b39bSJohn Wren Kennedy    log_mustnot datasetexists $snap
48d583b39bSJohn Wren Kennedydone
49d583b39bSJohn Wren Kennedy
50d583b39bSJohn Wren Kennedylog_pass "'zfs destroy -d <snap>' marks held snapshot for deferred destroy"
51