Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>


  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 #
  30 # Copyright (c) 2013 by Delphix. All rights reserved.
  31 #
  32 
  33 . $STF_SUITE/include/libtest.shlib
  34 . $STF_SUITE/tests/functional/snapshot/snapshot.cfg
  35 
  36 #
  37 # DESCRIPTION:
  38 #
  39 # Directory structure of snapshots reflects filesystem structure.
  40 #
  41 # STRATEGY:
  42 #
  43 # This test makes sure that the directory structure of snapshots is
  44 # a proper reflection of the filesystem the snapshot was taken of.
  45 #
  46 # 1. Create a simple directory structure of files and directories
  47 # 2. Take a snapshot of the filesystem
  48 # 3. Modify original filesystem
  49 # 4. Walk down the snapshot directory structure verifying it
  50 #    checking with both absolute and relative paths
  51 #
  52 
  53 verify_runnable "both"
  54 
  55 function cleanup
  56 {
  57         cd $SAVED_DIR
  58 
  59         if datasetexists $TESTPOOL/$TESTFS ; then
  60                 log_must $ZFS destroy -Rf $TESTPOOL/$TESTFS
  61         fi
  62 
  63         log_must $ZFS create $TESTPOOL/$TESTFS
  64         log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
  65 }
  66 
  67 function verify_structure {
  68 
  69         # check absolute paths
  70         DIR=$PWD
  71         verify_file $DIR/file1
  72         verify_file $DIR/file2
  73         verify_file $DIR/dir1/file3
  74         verify_file $DIR/dir1/file4
  75         verify_file $DIR/dir1/dir2/file5
  76         verify_file $DIR/dir1/dir2/file6
  77 
  78         verify_no_file $DIR/file99
  79 
  80         # check relative paths
  81         verify_file ./file1
  82         verify_file ./file2
  83         verify_file ./dir1/file3
  84         verify_file ./dir1/file4


 128                 log_fail "Directory $1 does not exist!"
 129         fi
 130 }
 131 
 132 log_assert "Directory structure of snapshots reflects filesystem structure."
 133 log_onexit cleanup
 134 
 135 SAVED_DIR=$PWD
 136 
 137 #
 138 # Create a directory structure with the following files
 139 #
 140 # ./file1
 141 # ./file2
 142 # ./dir1/file3
 143 # ./dir1/file4
 144 # ./dir1/dir2/file5
 145 # ./dir1/dir2/file6
 146 
 147 cd $TESTDIR
 148 $MKFILE 10m file1
 149 $MKFILE 20m file2
 150 $MKDIR dir1
 151 cd dir1
 152 $MKFILE 10m file3
 153 $MKFILE 20m file4
 154 $MKDIR dir2
 155 cd dir2
 156 $MKFILE 10m file5
 157 $MKFILE 20m file6
 158 
 159 # Now walk the directory structure verifying it
 160 cd $TESTDIR
 161 verify_structure
 162 
 163 # Take snapshots
 164 log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap_a
 165 log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap_b
 166 
 167 # Change the filesystem structure by renaming files in the original structure
 168 # The snapshot file structure should not change
 169 cd $TESTDIR
 170 log_must $MV file2 file99
 171 cd dir1
 172 log_must $MV file4 file99
 173 cd dir2
 174 log_must $MV file6 file99
 175 
 176 # verify the top level snapshot directories
 177 verify_dir $TESTDIR/.zfs
 178 verify_dir $TESTDIR/.zfs/snapshot
 179 verify_dir $TESTDIR/.zfs/snapshot/snap_a
 180 verify_dir $TESTDIR/.zfs/snapshot/snap_b
 181 
 182 cd $TESTDIR/.zfs/snapshot/snap_a
 183 verify_structure
 184 
 185 cd $TESTDIR/.zfs/snapshot/snap_b
 186 verify_structure
 187 
 188 cd $TESTDIR/.zfs
 189 verify_dir snapshot
 190 cd $TESTDIR/.zfs/snapshot
 191 verify_dir snap_a
 192 verify_dir snap_b
 193 
 194 cd snap_a


  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 #
  30 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  31 #
  32 
  33 . $STF_SUITE/include/libtest.shlib
  34 . $STF_SUITE/tests/functional/snapshot/snapshot.cfg
  35 
  36 #
  37 # DESCRIPTION:
  38 #
  39 # Directory structure of snapshots reflects filesystem structure.
  40 #
  41 # STRATEGY:
  42 #
  43 # This test makes sure that the directory structure of snapshots is
  44 # a proper reflection of the filesystem the snapshot was taken of.
  45 #
  46 # 1. Create a simple directory structure of files and directories
  47 # 2. Take a snapshot of the filesystem
  48 # 3. Modify original filesystem
  49 # 4. Walk down the snapshot directory structure verifying it
  50 #    checking with both absolute and relative paths
  51 #
  52 
  53 verify_runnable "both"
  54 
  55 function cleanup
  56 {
  57         cd $SAVED_DIR
  58 
  59         if datasetexists $TESTPOOL/$TESTFS ; then
  60                 log_must zfs destroy -Rf $TESTPOOL/$TESTFS
  61         fi
  62 
  63         log_must zfs create $TESTPOOL/$TESTFS
  64         log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
  65 }
  66 
  67 function verify_structure {
  68 
  69         # check absolute paths
  70         DIR=$PWD
  71         verify_file $DIR/file1
  72         verify_file $DIR/file2
  73         verify_file $DIR/dir1/file3
  74         verify_file $DIR/dir1/file4
  75         verify_file $DIR/dir1/dir2/file5
  76         verify_file $DIR/dir1/dir2/file6
  77 
  78         verify_no_file $DIR/file99
  79 
  80         # check relative paths
  81         verify_file ./file1
  82         verify_file ./file2
  83         verify_file ./dir1/file3
  84         verify_file ./dir1/file4


 128                 log_fail "Directory $1 does not exist!"
 129         fi
 130 }
 131 
 132 log_assert "Directory structure of snapshots reflects filesystem structure."
 133 log_onexit cleanup
 134 
 135 SAVED_DIR=$PWD
 136 
 137 #
 138 # Create a directory structure with the following files
 139 #
 140 # ./file1
 141 # ./file2
 142 # ./dir1/file3
 143 # ./dir1/file4
 144 # ./dir1/dir2/file5
 145 # ./dir1/dir2/file6
 146 
 147 cd $TESTDIR
 148 mkfile 10m file1
 149 mkfile 20m file2
 150 mkdir dir1
 151 cd dir1
 152 mkfile 10m file3
 153 mkfile 20m file4
 154 mkdir dir2
 155 cd dir2
 156 mkfile 10m file5
 157 mkfile 20m file6
 158 
 159 # Now walk the directory structure verifying it
 160 cd $TESTDIR
 161 verify_structure
 162 
 163 # Take snapshots
 164 log_must zfs snapshot $TESTPOOL/$TESTFS@snap_a
 165 log_must zfs snapshot $TESTPOOL/$TESTFS@snap_b
 166 
 167 # Change the filesystem structure by renaming files in the original structure
 168 # The snapshot file structure should not change
 169 cd $TESTDIR
 170 log_must mv file2 file99
 171 cd dir1
 172 log_must mv file4 file99
 173 cd dir2
 174 log_must mv file6 file99
 175 
 176 # verify the top level snapshot directories
 177 verify_dir $TESTDIR/.zfs
 178 verify_dir $TESTDIR/.zfs/snapshot
 179 verify_dir $TESTDIR/.zfs/snapshot/snap_a
 180 verify_dir $TESTDIR/.zfs/snapshot/snap_b
 181 
 182 cd $TESTDIR/.zfs/snapshot/snap_a
 183 verify_structure
 184 
 185 cd $TESTDIR/.zfs/snapshot/snap_b
 186 verify_structure
 187 
 188 cd $TESTDIR/.zfs
 189 verify_dir snapshot
 190 cd $TESTDIR/.zfs/snapshot
 191 verify_dir snap_a
 192 verify_dir snap_b
 193 
 194 cd snap_a