d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify 'zfs destroy [-rR]' succeeds as root.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Create two datasets in the storage pool
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Create fs,vol,ctr,snapshot and clones of snapshot in the two datasets
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Create clone in the second dataset for the snapshot in the first dataset
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Verify 'zfs destroy -r' fails to destroy dataset with clone outside it
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 5. Verify 'zfs destroy -R' succeeds to destroy dataset with clone outside it
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 6. Verify 'zfs destroy -r' succeeds to destroy dataset without clone outside it.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify that 'zfs destroy [-rR]' succeeds as root. "
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Preparations for testing
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy [[ ! -d $dir ]] && \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedychild_fs_snap_clone1=$ctr1/${TESTCLONE}_across_ctr
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedychild_fs1_snap_clone1=$ctr/${TESTCLONE1}_across_ctr
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Create two datasets in the storage pool
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Create children datasets fs,vol,snapshot in the datasets, and
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# clones across two datasets
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs set mountpoint=$child_fs_mntp $child_fs
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs set mountpoint=$child_fs1_mntp $child_fs1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfor snap in $child_fs_snap $child_fs1_snap; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfor clone in $child_fs_snap_clone $child_fs_snap_clone1; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfor clone in $child_fs1_snap_clone $child_fs1_snap_clone1; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "Verify that 'zfs destroy -r' fails to destroy dataset " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "with clone dependant outside it."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfor obj in $child_fs $child_fs1 $ctr $ctr1; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zfs destroy -r' fails to keep clone " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "dependant outside the hirearchy."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "Verify that 'zfs destroy -R' succeeds to destroy dataset " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "with clone dependant outside it."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zfs destroy -R' fails to destroy dataset with clone outside it."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "Verify that 'zfs destroy -r' succeeds to destroy dataset " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "without clone dependant outside it."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zfs destroy -r' fails to destroy dataset with clone outside it."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "'zfs destroy [-rR] succeeds as root."