]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/snapshot/rollback_001_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, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/snapshot
/snapshot.cfg
37 # Populate a file system and take a snapshot. Add some more files to the
38 # file system and rollback to the last snapshot. Verify no post snapshot
42 # 1. Empty a file system
43 # 2. Populate the file system
44 # 3. Take a snapshot of the file system
45 # 4. Add new files to the file system
46 # 5. Perform a rollback
47 # 6. Verify the snapshot and file system agree
50 verify_runnable
"both"
56 log_must zfs destroy
$SNAPFS
58 [[ -e $TESTDIR ]] && \
59 log_must
rm -rf $TESTDIR/* > /dev
/null
2>&1
62 log_assert
"Verify that a rollback to a previous snapshot succeeds."
66 [[ -n $TESTDIR ]] && \
67 log_must
rm -rf $TESTDIR/* > /dev
/null
2>&1
71 log_note
"Populate the $TESTDIR directory (prior to snapshot)"
73 while [[ $i -le $COUNT ]]; do
74 log_must file_write
-o create
-f $TESTDIR/before_file
$i \
75 -b $BLOCKSZ -c $NUM_WRITES -d $i
80 log_must zfs snapshot
$SNAPFS
82 FILE_COUNT
=`ls -Al $SNAPDIR | grep -v "total" | wc -l`
83 if [[ $FILE_COUNT -ne $COUNT ]]; then
85 log_fail
"AFTER: $SNAPFS contains $FILE_COUNT files(s)."
88 log_note
"Populate the $TESTDIR directory (post snapshot)"
90 while [[ $i -le $COUNT ]]; do
91 log_must file_write
-o create
-f $TESTDIR/after_file
$i \
92 -b $BLOCKSZ -c $NUM_WRITES -d $i
98 # Now rollback to latest snapshot
100 log_must zfs rollback
$SNAPFS
102 FILE_COUNT
=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l`
103 if [[ $FILE_COUNT -ne 0 ]]; then
105 log_fail
"$TESTDIR contains $FILE_COUNT after* files(s)."
108 FILE_COUNT
=`ls -Al $TESTDIR/before* 2> /dev/null \
109 | grep -v "total" | wc -l`
110 if [[ $FILE_COUNT -ne $COUNT ]]; then
112 log_fail
"$TESTDIR contains $FILE_COUNT before* files(s)."
115 log_pass
"The rollback operation succeeded."