clone_001_pos.ksh revision f38cb554a534c6df738be3f4d23327e69888e634
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
#
# DESCRIPTION:
# Create a snapshot from regular filesystem, volume,
# or filesystem upon volume, Build a clone file system
# from the snapshot and verify new files can be written.
#
# STRATEGY:
# 1. Create snapshot use 3 combination:
# - Regular filesystem
# - Regular volume
# - Filesystem upon volume
# 2. Clone a new file system from the snapshot
# 3. Verify the cloned file system is writable
#
verify_runnable "both"
# Setup array, 4 elements as a group, refer to:
# i+0: name of a snapshot
# i+1: mountpoint of the snapshot
# i+2: clone created from the snapshot
# i+3: mountpoint of the clone
"$SNAPFS1" "$SNAPDIR3" "$TESTPOOL/$TESTCLONE1" "" \
"$SNAPFS2" "$SNAPDIR2" "$TESTPOOL1/$TESTCLONE2" "$TESTDIR.2"
function setup_all
{
return 0
}
function cleanup_all
{
typeset -i i=0
i=0
while (( i < ${#args[*]} )); do
snapexists ${args[i]} && \
[[ -d ${args[i+3]} ]] && \
[[ -d ${args[i+1]} ]] && \
(( i = i + 4 ))
done
[[ -d $TESTDIR2 ]] && \
return 0
}
log_assert "Verify a cloned file system is writable."
[[ -n $TESTDIR ]] && \
typeset -i COUNT=10
typeset -i i=0
typeset -i j=1
log_must $FILE_WRITE -o create -f $mtpt/before_file$j \
-b $BLOCKSZ -c $NUM_WRITES -d $j
(( j = j + 1 ))
done
done
while (( i < ${#args[*]} )); do
#
# Take a snapshot of the test file system.
#
#
# Clone a new file system from the snapshot
#
if [[ -n ${args[i+3]} ]] ; then
log_must $ZFS set mountpoint=${args[i+3]} ${args[i+2]}
if [[ $FILE_COUNT -ne $COUNT ]]; then
log_fail "AFTER: ${args[i+3]} contains $FILE_COUNT files(s)."
fi
log_note "Verify the ${args[i+3]} directory is writable"
j=1
log_must $FILE_WRITE -o create -f ${args[i+3]}/after_file$j \
-b $BLOCKSZ -c $NUM_WRITES -d $j
(( j = j + 1 ))
done
if [[ $FILE_COUNT -ne $COUNT ]]; then
log_fail "${args[i+3]} contains $FILE_COUNT after* files(s)."
fi
fi
(( i = i + 4 ))
done
log_pass "The clone file system is writable."