]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/snapshot/clone_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 2009 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 # Create a snapshot from regular filesystem, volume,
38 # or filesystem upon volume, Build a clone file system
39 # from the snapshot and verify new files can be written.
42 # 1. Create snapshot use 3 combination:
43 # - Regular filesystem
45 # - Filesystem upon volume
46 # 2. Clone a new file system from the snapshot
47 # 3. Verify the cloned file system is writable
50 verify_runnable
"both"
52 # See issue: https://github.com/zfsonlinux/zfs/issues/6145
54 log_unsupported
"Test case occasionally fails"
57 # Setup array, 4 elements as a group, refer to:
58 # i+0: name of a snapshot
59 # i+1: mountpoint of the snapshot
60 # i+2: clone created from the snapshot
61 # i+3: mountpoint of the clone
63 set -A args
"$SNAPFS" "$SNAPDIR" "$TESTPOOL/$TESTCLONE" "$TESTDIR.0" \
64 "$SNAPFS1" "$SNAPDIR3" "$TESTPOOL/$TESTCLONE1" "" \
65 "$SNAPFS2" "$SNAPDIR2" "$TESTPOOL1/$TESTCLONE2" "$TESTDIR.2"
69 create_pool
$TESTPOOL1 ${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL
70 log_must zfs create
$TESTPOOL1/$TESTFS
71 log_must zfs
set mountpoint
=$TESTDIR2 $TESTPOOL1/$TESTFS
81 while (( i
< ${#args[*]} )); do
82 snapexists
${args[i]} && \
83 log_must zfs destroy
-Rf ${args[i]}
85 [[ -d ${args[i+3]} ]] && \
86 log_must
rm -rf ${args[i+3]}
88 [[ -d ${args[i+1]} ]] && \
89 log_must
rm -rf ${args[i+1]}
94 datasetexists
$TESTPOOL1/$TESTFS && \
95 log_must zfs destroy
-f $TESTPOOL1/$TESTFS
97 destroy_pool
$TESTPOOL1
99 [[ -d $TESTDIR2 ]] && \
100 log_must
rm -rf $TESTDIR2
105 log_assert
"Verify a cloned file system is writable."
107 log_onexit cleanup_all
111 [[ -n $TESTDIR ]] && \
112 log_must
rm -rf $TESTDIR/* > /dev
/null
2>&1
117 for mtpt
in $TESTDIR $TESTDIR2 ; do
118 log_note
"Populate the $mtpt directory (prior to snapshot)"
120 while [[ $j -le $COUNT ]]; do
121 log_must file_write
-o create
-f $mtpt/before_file
$j \
122 -b $BLOCKSZ -c $NUM_WRITES -d $j
128 while (( i
< ${#args[*]} )); do
130 # Take a snapshot of the test file system.
132 log_must zfs snapshot
${args[i]}
135 # Clone a new file system from the snapshot
137 log_must zfs clone
${args[i]} ${args[i+2]}
138 if [[ -n ${args[i+3]} ]] ; then
139 log_must zfs
set mountpoint
=${args[i+3]} ${args[i+2]}
141 FILE_COUNT
=`ls -Al ${args[i+3]} | grep -v "total" \
142 | grep -v "\.zfs" | wc -l`
143 if [[ $FILE_COUNT -ne $COUNT ]]; then
145 log_fail
"AFTER: ${args[i+3]} contains $FILE_COUNT files(s)."
148 log_note
"Verify the ${args[i+3]} directory is writable"
150 while [[ $j -le $COUNT ]]; do
151 log_must file_write
-o create
-f ${args[i+3]}/after_file
$j \
152 -b $BLOCKSZ -c $NUM_WRITES -d $j
156 FILE_COUNT
=`ls -Al ${args[i+3]}/after* | grep -v "total" | wc -l`
157 if [[ $FILE_COUNT -ne $COUNT ]]; then
159 log_fail
"${args[i+3]} contains $FILE_COUNT after* files(s)."
166 log_pass
"The clone file system is writable."