Mercurial > illumos > illumos-gate
comparison usr/src/test/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_003_pos.ksh @ 13899:0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
3312 Add a testrunner package for OS unit tests
3313 Add a testrunner package to convert ZFS tests from STF
Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by: Will Guyette <will.guyette@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Henrik Mattson <henrik.mattson@delphix.com>
Reviewed by: Sonu Pillai <sonu.pillai@delphix.com>
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | John Wren Kennedy <john.kennedy@delphix.com> |
---|---|
date | Wed, 05 Dec 2012 22:04:50 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13898:7f822b09519b | 13899:0bcf78798346 |
---|---|
1 #!/bin/ksh -p | |
2 # | |
3 # CDDL HEADER START | |
4 # | |
5 # The contents of this file are subject to the terms of the | |
6 # Common Development and Distribution License (the "License"). | |
7 # You may not use this file except in compliance with the License. | |
8 # | |
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
10 # or http://www.opensolaris.org/os/licensing. | |
11 # See the License for the specific language governing permissions | |
12 # and limitations under the License. | |
13 # | |
14 # When distributing Covered Code, include this CDDL HEADER in each | |
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
16 # If applicable, add the following below this CDDL HEADER, with the | |
17 # fields enclosed by brackets "[]" replaced with your own identifying | |
18 # information: Portions Copyright [yyyy] [name of copyright owner] | |
19 # | |
20 # CDDL HEADER END | |
21 # | |
22 | |
23 # | |
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
25 # Use is subject to license terms. | |
26 # | |
27 | |
28 # | |
29 # Copyright (c) 2012 by Delphix. All rights reserved. | |
30 # | |
31 | |
32 . $STF_SUITE/include/libtest.shlib | |
33 . $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg | |
34 | |
35 # | |
36 # DESCRIPTION: | |
37 # Verify 'zfs destroy [-rR]' succeeds as root. | |
38 # | |
39 # STRATEGY: | |
40 # 1. Create two datasets in the storage pool | |
41 # 2. Create fs,vol,ctr,snapshot and clones of snapshot in the two datasets | |
42 # 3. Create clone in the second dataset for the snapshot in the first dataset | |
43 # 4. Verify 'zfs destroy -r' fails to destroy dataset with clone outside it | |
44 # 5. Verify 'zfs destroy -R' succeeds to destroy dataset with clone outside it | |
45 # 6. Verify 'zfs destroy -r' succeeds to destroy dataset without clone outside it. | |
46 # | |
47 | |
48 verify_runnable "both" | |
49 | |
50 function cleanup | |
51 { | |
52 for obj in $ctr2 $ctr1 $ctr; do | |
53 datasetexists $obj && \ | |
54 log_must $ZFS destroy -Rf $obj | |
55 done | |
56 | |
57 for mntp in $TESTDIR1 $TESTDIR2; do | |
58 [[ -d $mntp ]] && \ | |
59 log_must $RM -rf $mntp | |
60 done | |
61 } | |
62 | |
63 log_assert "Verify that 'zfs destroy [-rR]' succeeds as root. " | |
64 | |
65 log_onexit cleanup | |
66 | |
67 # | |
68 # Preparations for testing | |
69 # | |
70 for dir in $TESTDIR1 $TESTDIR2; do | |
71 [[ ! -d $dir ]] && \ | |
72 log_must $MKDIR -p $dir | |
73 done | |
74 | |
75 ctr=$TESTPOOL/$TESTCTR | |
76 ctr1=$TESTPOOL/$TESTCTR1 | |
77 ctr2=$ctr/$TESTCTR2 | |
78 ctr3=$ctr1/$TESTCTR2 | |
79 child_fs=$ctr/$TESTFS1 | |
80 child_fs1=$ctr1/$TESTFS2 | |
81 child_fs_mntp=$TESTDIR1 | |
82 child_fs1_mntp=$TESTDIR2 | |
83 child_vol=$ctr/$TESTVOL | |
84 child_vol1=$ctr1/$TESTVOL | |
85 child_fs_snap=$child_fs@snap | |
86 child_fs1_snap=$child_fs1@snap | |
87 child_fs_snap_clone=$ctr/$TESTCLONE | |
88 child_fs_snap_clone1=$ctr1/${TESTCLONE}_across_ctr | |
89 child_fs_snap_clone2=$ctr2/$TESTCLONE2 | |
90 child_fs1_snap_clone=$ctr1/$TESTCLONE1 | |
91 child_fs1_snap_clone1=$ctr/${TESTCLONE1}_across_ctr | |
92 | |
93 # | |
94 # Create two datasets in the storage pool | |
95 # | |
96 log_must $ZFS create $ctr | |
97 log_must $ZFS create $ctr1 | |
98 | |
99 # | |
100 # Create children datasets fs,vol,snapshot in the datasets, and | |
101 # clones across two datasets | |
102 # | |
103 log_must $ZFS create $ctr2 | |
104 | |
105 for fs in $child_fs $child_fs1; do | |
106 log_must $ZFS create $fs | |
107 done | |
108 | |
109 log_must $ZFS set mountpoint=$child_fs_mntp $child_fs | |
110 log_must $ZFS set mountpoint=$child_fs1_mntp $child_fs1 | |
111 | |
112 for snap in $child_fs_snap $child_fs1_snap; do | |
113 log_must $ZFS snapshot $snap | |
114 done | |
115 | |
116 if is_global_zone ; then | |
117 for vol in $child_vol $child_vol1; do | |
118 log_must $ZFS create -V $VOLSIZE $vol | |
119 done | |
120 fi | |
121 | |
122 for clone in $child_fs_snap_clone $child_fs_snap_clone1; do | |
123 log_must $ZFS clone $child_fs_snap $clone | |
124 done | |
125 | |
126 | |
127 for clone in $child_fs1_snap_clone $child_fs1_snap_clone1; do | |
128 log_must $ZFS clone $child_fs1_snap $clone | |
129 done | |
130 | |
131 log_note "Verify that 'zfs destroy -r' fails to destroy dataset " \ | |
132 "with clone dependant outside it." | |
133 | |
134 for obj in $child_fs $child_fs1 $ctr $ctr1; do | |
135 log_mustnot $ZFS destroy -r $obj | |
136 datasetexists $obj || \ | |
137 log_fail "'zfs destroy -r' fails to keep clone " \ | |
138 "dependant outside the hirearchy." | |
139 done | |
140 | |
141 | |
142 log_note "Verify that 'zfs destroy -R' succeeds to destroy dataset " \ | |
143 "with clone dependant outside it." | |
144 | |
145 log_must $ZFS destroy -R $ctr1 | |
146 datasetexists $ctr1 && \ | |
147 log_fail "'zfs destroy -R' fails to destroy dataset with clone outside it." | |
148 | |
149 log_note "Verify that 'zfs destroy -r' succeeds to destroy dataset " \ | |
150 "without clone dependant outside it." | |
151 | |
152 log_must $ZFS destroy -r $ctr | |
153 datasetexists $ctr && \ | |
154 log_fail "'zfs destroy -r' fails to destroy dataset with clone outside it." | |
155 | |
156 log_pass "'zfs destroy [-rR] succeeds as root." |