]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - zfs/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh
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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/snapshot
/snapshot.cfg
37 # Verify that rollbacks are with respect to the latest snapshot.
40 # 1. Empty a file system
41 # 2. Populate the file system
42 # 3. Take a snapshot of the file system
43 # 4. Add new files to the file system
45 # 6. Remove the original files
46 # 7. Perform a rollback
47 # 8. Verify the latest snapshot and file system agree
50 verify_runnable
"both"
56 log_must
$ZFS destroy
$SNAPFS.1
60 log_must
$ZFS destroy
$SNAPFS
62 [[ -e $TESTDIR ]] && \
63 log_must
$RM -rf $TESTDIR/* > /dev
/null
2>&1
66 log_assert
"Verify rollback is with respect to latest snapshot."
70 [[ -n $TESTDIR ]] && \
71 log_must
$RM -rf $TESTDIR/* > /dev
/null
2>&1
75 log_note
"Populate the $TESTDIR directory (prior to first snapshot)"
77 while [[ $i -le $COUNT ]]; do
78 log_must
$FILE_WRITE -o create
-f $TESTDIR/original_file
$i \
79 -b $BLOCKSZ -c $NUM_WRITES -d $i
84 log_must
$ZFS snapshot
$SNAPFS
86 FILE_COUNT
=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
87 if [[ $FILE_COUNT -ne $COUNT ]]; then
89 log_fail
"AFTER: $SNAPFS contains $FILE_COUNT files(s)."
92 log_note
"Populate the $TESTDIR directory (prior to second snapshot)"
94 while [[ $i -le $COUNT ]]; do
95 log_must
$FILE_WRITE -o create
-f $TESTDIR/afterfirst_file
$i \
96 -b $BLOCKSZ -c $NUM_WRITES -d $i
101 log_must
$ZFS snapshot
$SNAPFS.1
103 log_note
"Populate the $TESTDIR directory (Post second snapshot)"
105 while [[ $i -le $COUNT ]]; do
106 log_must
$FILE_WRITE -o create
-f $TESTDIR/aftersecond_file
$i \
107 -b $BLOCKSZ -c $NUM_WRITES -d $i
112 [[ -n $TESTDIR ]] && \
113 log_must
$RM -rf $TESTDIR/original_file
* > /dev
/null
2>&1
116 # Now rollback to latest snapshot
118 log_must
$ZFS rollback
$SNAPFS.1
120 FILE_COUNT
=`$LS -Al $TESTDIR/aftersecond* 2> /dev/null \
121 | $GREP -v "total" | wc -l`
122 if [[ $FILE_COUNT -ne 0 ]]; then
124 log_fail
"$TESTDIR contains $FILE_COUNT aftersecond* files(s)."
127 FILE_COUNT
=`$LS -Al $TESTDIR/original* $TESTDIR/afterfirst*| $GREP -v "total" | wc -l`
128 if [[ $FILE_COUNT -ne 20 ]]; then
130 log_fail
"$TESTDIR contains $FILE_COUNT original* files(s)."
133 log_pass
"The rollback to the latest snapshot succeeded."