]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
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 2008 Sun Microsystems, Inc. All rights reserved. | |
25 | # Use is subject to license terms. | |
26 | # | |
27 | ||
28 | ||
29 | # | |
c1d9abf9 | 30 | # Copyright (c) 2013, 2016 by Delphix. All rights reserved. |
6bb24f4d BB |
31 | # |
32 | ||
33 | . $STF_SUITE/include/libtest.shlib | |
34 | . $STF_SUITE/tests/functional/snapshot/snapshot.cfg | |
35 | ||
36 | # | |
37 | # DESCRIPTION: | |
38 | # Verify renamed snapshots via mv can be destroyed | |
39 | # | |
40 | # STRATEGY: | |
41 | # 1. Create snapshot | |
42 | # 2. Rename the snapshot via mv command | |
43 | # 2. Verify destroying the renamed snapshot via 'zfs destroy' succeeds | |
44 | # | |
45 | ||
46 | verify_runnable "both" | |
47 | ||
48 | function cleanup | |
49 | { | |
50 | datasetexists $SNAPFS && \ | |
c1d9abf9 | 51 | log_must zfs destroy -Rf $SNAPFS |
6bb24f4d | 52 | datasetexists $TESTPOOL/$TESTFS@snap_a && \ |
c1d9abf9 | 53 | log_must zfs destroy -Rf $TESTPOOL/$TESTFS@snap_a |
95401cb6 BB |
54 | datasetexists $TESTPOOL/$TESTFS@snap_b && \ |
55 | log_must zfs destroy -Rf $TESTPOOL/$TESTFS@snap_b | |
6bb24f4d | 56 | datasetexists $TESTPOOL/$TESTCLONE@snap_a && \ |
c1d9abf9 | 57 | log_must zfs destroy -Rf $TESTPOOL/$TESTCLONE@snap_a |
6bb24f4d BB |
58 | |
59 | datasetexists $TESTPOOL/$TESTCLONE && \ | |
c1d9abf9 | 60 | log_must zfs destroy $TESTPOOL/$TESTCLONE |
6bb24f4d | 61 | datasetexists $TESTPOOL/$TESTFS && \ |
c1d9abf9 | 62 | log_must zfs destroy $TESTPOOL/$TESTFS |
6bb24f4d | 63 | |
c1d9abf9 JWK |
64 | log_must zfs create $TESTPOOL/$TESTFS |
65 | log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS | |
6bb24f4d BB |
66 | } |
67 | ||
68 | log_assert "Verify renamed snapshots via mv can be destroyed." | |
69 | log_onexit cleanup | |
70 | ||
71 | # scenario 1 | |
72 | ||
c1d9abf9 JWK |
73 | log_must zfs snapshot $SNAPFS |
74 | log_must mv $TESTDIR/$SNAPROOT/$TESTSNAP $TESTDIR/$SNAPROOT/snap_a | |
6bb24f4d BB |
75 | |
76 | datasetexists $TESTPOOL/$TESTFS@snap_a || \ | |
77 | log_fail "rename snapshot via mv in .zfs/snapshot fails." | |
c1d9abf9 | 78 | log_must zfs destroy $TESTPOOL/$TESTFS@snap_a |
6bb24f4d BB |
79 | |
80 | # scenario 2 | |
81 | ||
c1d9abf9 JWK |
82 | log_must zfs snapshot $SNAPFS |
83 | log_must zfs clone $SNAPFS $TESTPOOL/$TESTCLONE | |
95401cb6 | 84 | log_must mv $TESTDIR/$SNAPROOT/$TESTSNAP $TESTDIR/$SNAPROOT/snap_b |
6bb24f4d | 85 | |
95401cb6 | 86 | datasetexists $TESTPOOL/$TESTFS@snap_b || \ |
6bb24f4d | 87 | log_fail "rename snapshot via mv in .zfs/snapshot fails." |
c1d9abf9 | 88 | log_must zfs promote $TESTPOOL/$TESTCLONE |
6bb24f4d | 89 | # promote back to $TESTPOOL/$TESTFS for scenario 3 |
c1d9abf9 JWK |
90 | log_must zfs promote $TESTPOOL/$TESTFS |
91 | log_must zfs destroy $TESTPOOL/$TESTCLONE | |
95401cb6 | 92 | log_must zfs destroy $TESTPOOL/$TESTFS@snap_b |
6bb24f4d BB |
93 | |
94 | # scenario 3 | |
95 | ||
c1d9abf9 JWK |
96 | log_must zfs snapshot $SNAPFS |
97 | log_must zfs clone $SNAPFS $TESTPOOL/$TESTCLONE | |
98 | log_must zfs rename $SNAPFS $TESTPOOL/$TESTFS@snap_a | |
99 | log_must zfs promote $TESTPOOL/$TESTCLONE | |
100 | log_must zfs destroy $TESTPOOL/$TESTFS | |
101 | log_must zfs destroy $TESTPOOL/$TESTCLONE@snap_a | |
6bb24f4d BB |
102 | |
103 | log_pass "Verify renamed snapshots via mv can be destroyed." |