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# Destroy of held snapshot should fail. 24d583b39bSJohn Wren Kennedy# 25d583b39bSJohn Wren Kennedy# 1. Create test environment without clones. 26d583b39bSJohn Wren Kennedy# 2. 'zfs hold <tag> <snap>' 27d583b39bSJohn Wren Kennedy# 3. 'zfs destroy <snap>' should fail. 28d583b39bSJohn Wren Kennedy# 4. Verify snapshot still exists. 29d583b39bSJohn Wren Kennedy# 5. 'zfs release <tag> <snap>' 30d583b39bSJohn Wren Kennedy# 6. Verify that we can destroy the snapshot. 31d583b39bSJohn Wren Kennedy# 32d583b39bSJohn Wren Kennedy################################################################################ 33d583b39bSJohn Wren Kennedy 34d583b39bSJohn Wren Kennedylog_assert "zfs destroy of held snapshots fails" 35d583b39bSJohn Wren Kennedylog_onexit cleanup_testenv 36d583b39bSJohn Wren Kennedy 37d583b39bSJohn Wren Kennedysetup_testenv snap 38d583b39bSJohn Wren Kennedy 39d583b39bSJohn Wren Kennedyfor dstype in FS VOL; do 40d583b39bSJohn Wren Kennedy snap=$(eval echo \$${dstype}SNAP) 41*1d32ba66SJohn Wren Kennedy log_must zfs hold zfstest $snap 42*1d32ba66SJohn Wren Kennedy log_mustnot zfs destroy $snap 43d583b39bSJohn Wren Kennedy log_must datasetexists $snap 44*1d32ba66SJohn Wren Kennedy log_must zfs release zfstest $snap 45*1d32ba66SJohn Wren Kennedy log_must zfs destroy $snap 46d583b39bSJohn Wren Kennedy log_mustnot datasetexists $snap 47d583b39bSJohn Wren Kennedydone 48d583b39bSJohn Wren Kennedy 49d583b39bSJohn Wren Kennedylog_pass "zfs destroy of held snapshots fails" 50