1*d583b39bSJohn Wren Kennedy#!/bin/ksh -p
2*d583b39bSJohn Wren Kennedy#
3*d583b39bSJohn Wren Kennedy# CDDL HEADER START
4*d583b39bSJohn Wren Kennedy#
5*d583b39bSJohn Wren Kennedy# The contents of this file are subject to the terms of the
6*d583b39bSJohn Wren Kennedy# Common Development and Distribution License (the "License").
7*d583b39bSJohn Wren Kennedy# You may not use this file except in compliance with the License.
8*d583b39bSJohn Wren Kennedy#
9*d583b39bSJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*d583b39bSJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing.
11*d583b39bSJohn Wren Kennedy# See the License for the specific language governing permissions
12*d583b39bSJohn Wren Kennedy# and limitations under the License.
13*d583b39bSJohn Wren Kennedy#
14*d583b39bSJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
15*d583b39bSJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*d583b39bSJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
17*d583b39bSJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
18*d583b39bSJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
19*d583b39bSJohn Wren Kennedy#
20*d583b39bSJohn Wren Kennedy# CDDL HEADER END
21*d583b39bSJohn Wren Kennedy#
22*d583b39bSJohn Wren Kennedy
23*d583b39bSJohn Wren Kennedy#
24*d583b39bSJohn Wren Kennedy# Copyright (c) 2012 by Delphix. All rights reserved.
25*d583b39bSJohn Wren Kennedy#
26*d583b39bSJohn Wren Kennedy
27*d583b39bSJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib
28*d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
29*d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
30*d583b39bSJohn Wren Kennedy
31*d583b39bSJohn Wren Kennedy################################################################################
32*d583b39bSJohn Wren Kennedy#
33*d583b39bSJohn Wren Kennedy# 'zfs destroy -d <snap>' should mark snapshot for deferred destroy when
34*d583b39bSJohn Wren Kennedy# clone exists and destroy when clone is destroyed.
35*d583b39bSJohn Wren Kennedy#
36*d583b39bSJohn Wren Kennedy# 1. Create test environment with clones.
37*d583b39bSJohn Wren Kennedy# 2. 'zfs destroy -d <snap>'
38*d583b39bSJohn Wren Kennedy# 3. Verify snapshot is marked for deferred destroy.
39*d583b39bSJohn Wren Kennedy# 4. 'zfs destroy <clone>'
40*d583b39bSJohn Wren Kennedy# 3. Verify that the snapshot and clone are destroyed.
41*d583b39bSJohn Wren Kennedy#
42*d583b39bSJohn Wren Kennedy################################################################################
43*d583b39bSJohn Wren Kennedy
44*d583b39bSJohn Wren Kennedylog_assert "'zfs destroy -d <snap>' marks cloned snapshot for deferred destroy"
45*d583b39bSJohn Wren Kennedylog_onexit cleanup_testenv
46*d583b39bSJohn Wren Kennedy
47*d583b39bSJohn Wren Kennedysetup_testenv clone
48*d583b39bSJohn Wren Kennedy
49*d583b39bSJohn Wren Kennedyfor dstype in FS VOL; do
50*d583b39bSJohn Wren Kennedy    snap=$(eval echo \$${dstype}SNAP)
51*d583b39bSJohn Wren Kennedy    clone=$(eval echo \$${dstype}CLONE)
52*d583b39bSJohn Wren Kennedy    log_must $ZFS destroy -d $snap
53*d583b39bSJohn Wren Kennedy    log_must datasetexists $snap
54*d583b39bSJohn Wren Kennedy    log_must eval "[[ $(get_prop defer_destroy $snap) == 'on' ]]"
55*d583b39bSJohn Wren Kennedy    log_must $ZFS destroy $clone
56*d583b39bSJohn Wren Kennedy    log_mustnot datasetexists $snap
57*d583b39bSJohn Wren Kennedy    log_mustnot datasetexists $clone
58*d583b39bSJohn Wren Kennedydone
59*d583b39bSJohn Wren Kennedy
60*d583b39bSJohn Wren Kennedylog_pass "'zfs destroy -d <snap>' marks cloned snapshot for deferred destroy"
61