Add the ZFS Test Suite

Add the ZFS Test Suite and test-runner framework from illumos.
This is a continuation of the work done by Turbo Fredriksson to
port the ZFS Test Suite to Linux.  While this work was originally
conceived as a stand alone project integrating it directly with
the ZoL source tree has several advantages:

  * Allows the ZFS Test Suite to be packaged in zfs-test package.
    * Facilitates easy integration with the CI testing.
    * Users can locally run the ZFS Test Suite to validate ZFS.
      This testing should ONLY be done on a dedicated test system
      because the ZFS Test Suite in its current form is destructive.
  * Allows the ZFS Test Suite to be run directly in the ZoL source
    tree enabled developers to iterate quickly during development.
  * Developers can easily add/modify tests in the framework as
    features are added or functionality is changed.  The tests
    will then always be in sync with the implementation.

Full documentation for how to run the ZFS Test Suite is available
in the tests/README.md file.

Warning: This test suite is designed to be run on a dedicated test
system.  It will make modifications to the system including, but
not limited to, the following.

  * Adding new users
  * Adding new groups
  * Modifying the following /proc files:
    * /proc/sys/kernel/core_pattern
    * /proc/sys/kernel/core_uses_pid
  * Creating directories under /

Notes:
  * Not all of the test cases are expected to pass and by default
    these test cases are disabled.  The failures are primarily due
    to assumption made for illumos which are invalid under Linux.
  * When updating these test cases it should be done in as generic
    a way as possible so the patch can be submitted back upstream.
    Most existing library functions have been updated to be Linux
    aware, and the following functions and variables have been added.
    * Functions:
      * is_linux          - Used to wrap a Linux specific section.
      * block_device_wait - Waits for block devices to be added to /dev/.
    * Variables:            Linux          Illumos
      * ZVOL_DEVDIR         "/dev/zvol"    "/dev/zvol/dsk"
      * ZVOL_RDEVDIR        "/dev/zvol"    "/dev/zvol/rdsk"
      * DEV_DSKDIR          "/dev"         "/dev/dsk"
      * DEV_RDSKDIR         "/dev"         "/dev/rdsk"
      * NEWFS_DEFAULT_FS    "ext2"         "ufs"
  * Many of the disabled test cases fail because 'zfs/zpool destroy'
    returns EBUSY.  This is largely causes by the asynchronous nature
    of device handling on Linux and is expected, the impacted test
    cases will need to be updated to handle this.
  * There are several test cases which have been disabled because
    they can trigger a deadlock.  A primary example of this is to
    recursively create zpools within zpools.  These tests have been
    disabled until the root issue can be addressed.
  * Illumos specific utilities such as (mkfile) should be added to
    the tests/zfs-tests/cmd/ directory.  Custom programs required by
    the test scripts can also be added here.
  * SELinux should be either is permissive mode or disabled when
    running the tests.  The test cases should be updated to conform
    to a standard policy.
  * Redundant test functionality has been removed (zfault.sh).
  * Existing test scripts (zconfig.sh) should be migrated to use
    the framework for consistency and ease of testing.
  * The DISKS environment variable currently only supports loopback
    devices because of how the ZFS Test Suite expects partitions to
    be named (p1, p2, etc).  Support must be added to generate the
    correct partition name based on the device location and name.
  * The ZFS Test Suite is part of the illumos code base at:
    https://github.com/illumos/illumos-gate/tree/master/usr/src/test

Original-patch-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #6
Closes #1534
This commit is contained in:
Brian Behlendorf
2015-07-01 15:23:09 -07:00
parent 887d1e60ef
commit 6bb24f4dc7
1243 changed files with 89497 additions and 1042 deletions
@@ -0,0 +1,26 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/snapshot
dist_pkgdata_SCRIPTS = \
snapshot.cfg \
setup.ksh \
cleanup.ksh \
clone_001_pos.ksh \
rollback_001_pos.ksh \
rollback_002_pos.ksh \
rollback_003_pos.ksh \
snapshot_001_pos.ksh \
snapshot_002_pos.ksh \
snapshot_003_pos.ksh \
snapshot_004_pos.ksh \
snapshot_005_pos.ksh \
snapshot_006_pos.ksh \
snapshot_007_pos.ksh \
snapshot_008_pos.ksh \
snapshot_009_pos.ksh \
snapshot_010_pos.ksh \
snapshot_011_pos.ksh \
snapshot_012_pos.ksh \
snapshot_013_pos.ksh \
snapshot_014_pos.ksh \
snapshot_015_pos.ksh \
snapshot_016_pos.ksh \
snapshot_017_pos.ksh
+34
View File
@@ -0,0 +1,34 @@
#!/bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
default_container_cleanup
+161
View File
@@ -0,0 +1,161 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# 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
set -A args "$SNAPFS" "$SNAPDIR" "$TESTPOOL/$TESTCLONE" "$TESTDIR.0" \
"$SNAPFS1" "$SNAPDIR3" "$TESTPOOL/$TESTCLONE1" "" \
"$SNAPFS2" "$SNAPDIR2" "$TESTPOOL1/$TESTCLONE2" "$TESTDIR.2"
function setup_all
{
create_pool $TESTPOOL1 ${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL
log_must $ZFS create $TESTPOOL1/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR2 $TESTPOOL1/$TESTFS
return 0
}
function cleanup_all
{
typeset -i i=0
i=0
while (( i < ${#args[*]} )); do
snapexists ${args[i]} && \
log_must $ZFS destroy -Rf ${args[i]}
[[ -d ${args[i+3]} ]] && \
log_must $RM -rf ${args[i+3]}
[[ -d ${args[i+1]} ]] && \
log_must $RM -rf ${args[i+1]}
(( i = i + 4 ))
done
datasetexists $TESTPOOL1/$TESTFS && \
log_must $ZFS destroy -f $TESTPOOL1/$TESTFS
destroy_pool $TESTPOOL1
[[ -d $TESTDIR2 ]] && \
log_must $RM -rf $TESTDIR2
return 0
}
log_assert "Verify a cloned file system is writable."
log_onexit cleanup_all
setup_all
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
typeset -i i=0
for mtpt in $TESTDIR $TESTDIR2 ; do
log_note "Populate the $mtpt directory (prior to snapshot)"
typeset -i j=1
while [[ $j -le $COUNT ]]; do
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.
#
log_must $ZFS snapshot ${args[i]}
#
# Clone a new file system from the snapshot
#
log_must $ZFS clone ${args[i]} ${args[i+2]}
if [[ -n ${args[i+3]} ]] ; then
log_must $ZFS set mountpoint=${args[i+3]} ${args[i+2]}
FILE_COUNT=`$LS -Al ${args[i+3]} | $GREP -v "total" \
| $GREP -v "\.zfs" | wc -l`
if [[ $FILE_COUNT -ne $COUNT ]]; then
$LS -Al ${args[i+3]}
log_fail "AFTER: ${args[i+3]} contains $FILE_COUNT files(s)."
fi
log_note "Verify the ${args[i+3]} directory is writable"
j=1
while [[ $j -le $COUNT ]]; do
log_must $FILE_WRITE -o create -f ${args[i+3]}/after_file$j \
-b $BLOCKSZ -c $NUM_WRITES -d $j
(( j = j + 1 ))
done
FILE_COUNT=`$LS -Al ${args[i+3]}/after* | $GREP -v "total" | wc -l`
if [[ $FILE_COUNT -ne $COUNT ]]; then
$LS -Al ${args[i+3]}
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."
@@ -0,0 +1,115 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Populate a file system and take a snapshot. Add some more files to the
# file system and rollback to the last snapshot. Verify no post snapshot
# file exist.
#
# STRATEGY:
# 1. Empty a file system
# 2. Populate the file system
# 3. Take a snapshot of the file system
# 4. Add new files to the file system
# 5. Perform a rollback
# 6. Verify the snapshot and file system agree
#
verify_runnable "both"
function cleanup
{
snapexists $SNAPFS
[[ $? -eq 0 ]] && \
log_must $ZFS destroy $SNAPFS
[[ -e $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
}
log_assert "Verify that a rollback to a previous snapshot succeeds."
log_onexit cleanup
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
log_note "Populate the $TESTDIR directory (prior to snapshot)"
typeset -i i=1
while [[ $i -le $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/before_file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
log_must $ZFS snapshot $SNAPFS
FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
if [[ $FILE_COUNT -ne $COUNT ]]; then
$LS -Al $SNAPDIR
log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)."
fi
log_note "Populate the $TESTDIR directory (post snapshot)"
typeset -i i=1
while [[ $i -le $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/after_file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
#
# Now rollback to latest snapshot
#
log_must $ZFS rollback $SNAPFS
FILE_COUNT=`$LS -Al $TESTDIR/after* 2> /dev/null | $GREP -v "total" | wc -l`
if [[ $FILE_COUNT -ne 0 ]]; then
$LS -Al $TESTDIR
log_fail "$TESTDIR contains $FILE_COUNT after* files(s)."
fi
FILE_COUNT=`$LS -Al $TESTDIR/before* 2> /dev/null \
| $GREP -v "total" | wc -l`
if [[ $FILE_COUNT -ne $COUNT ]]; then
$LS -Al $TESTDIR
log_fail "$TESTDIR contains $FILE_COUNT before* files(s)."
fi
log_pass "The rollback operation succeeded."
@@ -0,0 +1,133 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify that rollbacks are with respect to the latest snapshot.
#
# STRATEGY:
# 1. Empty a file system
# 2. Populate the file system
# 3. Take a snapshot of the file system
# 4. Add new files to the file system
# 5. Take a snapshot
# 6. Remove the original files
# 7. Perform a rollback
# 8. Verify the latest snapshot and file system agree
#
verify_runnable "both"
function cleanup
{
snapexists $SNAPFS.1
[[ $? -eq 0 ]] && \
log_must $ZFS destroy $SNAPFS.1
snapexists $SNAPFS
[[ $? -eq 0 ]] && \
log_must $ZFS destroy $SNAPFS
[[ -e $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
}
log_assert "Verify rollback is with respect to latest snapshot."
log_onexit cleanup
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
log_note "Populate the $TESTDIR directory (prior to first snapshot)"
typeset -i i=1
while [[ $i -le $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/original_file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
log_must $ZFS snapshot $SNAPFS
FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
if [[ $FILE_COUNT -ne $COUNT ]]; then
$LS -Al $SNAPDIR
log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)."
fi
log_note "Populate the $TESTDIR directory (prior to second snapshot)"
typeset -i i=1
while [[ $i -le $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/afterfirst_file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
log_must $ZFS snapshot $SNAPFS.1
log_note "Populate the $TESTDIR directory (Post second snapshot)"
typeset -i i=1
while [[ $i -le $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/aftersecond_file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/original_file* > /dev/null 2>&1
#
# Now rollback to latest snapshot
#
log_must $ZFS rollback $SNAPFS.1
FILE_COUNT=`$LS -Al $TESTDIR/aftersecond* 2> /dev/null \
| $GREP -v "total" | wc -l`
if [[ $FILE_COUNT -ne 0 ]]; then
$LS -Al $TESTDIR
log_fail "$TESTDIR contains $FILE_COUNT aftersecond* files(s)."
fi
FILE_COUNT=`$LS -Al $TESTDIR/original* $TESTDIR/afterfirst*| $GREP -v "total" | wc -l`
if [[ $FILE_COUNT -ne 20 ]]; then
$LS -Al $TESTDIR
log_fail "$TESTDIR contains $FILE_COUNT original* files(s)."
fi
log_pass "The rollback to the latest snapshot succeeded."
@@ -0,0 +1,106 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify that rollbacks succeed when there are nested file systems.
#
# STRATEGY:
# 1) Snapshot an empty file system and rollback
# 2) Create a file in the file system
# 3) Rollback the file system to empty
# 4) Create a nested file system with the same name as the file created in (2)
# 5) Verify a rollback succeeds
#
verify_runnable "both"
function cleanup
{
typeset snap=""
typeset fs=""
export __ZFS_POOL_RESTRICT="$TESTPOOL"
log_must $ZFS mount -a
unset __ZFS_POOL_RESTRICT
for snap in "$SNAPPOOL.1" "$SNAPPOOL"
do
snapexists $snap
[[ $? -eq 0 ]] && \
log_must $ZFS destroy $snap
done
for fs in "$TESTPOOL/$TESTFILE/$TESTFILE.1" "$TESTPOOL/$TESTFILE"
do
datasetexists $fs
[[ $? -eq 0 ]] && \
log_must $ZFS destroy -r $fs
done
[[ -e /$TESTPOOL ]] && \
log_must $RM -rf $TESTPOOL/*
}
log_assert "Verify rollback succeeds when there are nested file systems."
log_onexit cleanup
log_must $ZFS snapshot $SNAPPOOL
log_must $ZFS rollback $SNAPPOOL
log_mustnot $ZFS snapshot $SNAPPOOL
log_must $TOUCH /$TESTPOOL/$TESTFILE
log_must $ZFS rollback $SNAPPOOL
log_must $ZFS create $TESTPOOL/$TESTFILE
log_must $ZFS rollback $SNAPPOOL
log_note "Verify rollback of multiple nested file systems succeeds."
log_must $ZFS snapshot $TESTPOOL/$TESTFILE@$TESTSNAP
log_must $ZFS snapshot $SNAPPOOL.1
export __ZFS_POOL_RESTRICT="$TESTPOOL"
log_must $ZFS unmount -a
log_must $ZFS mount -a
unset __ZFS_POOL_RESTRICT
log_must $TOUCH /$TESTPOOL/$TESTFILE/$TESTFILE.1
log_must $ZFS rollback $SNAPPOOL.1
log_pass "Rollbacks succeed when nested file systems are present."
+36
View File
@@ -0,0 +1,36 @@
#!/bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
DISK=${DISKS%% *}
default_container_volume_setup ${DISK}
@@ -0,0 +1,53 @@
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
export TESTFILE=testfile-snapshot
export SNAPROOT=".zfs/snapshot"
export SNAPPOOL="$TESTPOOL@$TESTSNAP"
export SNAPFS="$TESTPOOL/$TESTFS@$TESTSNAP"
export SNAPFS1="$TESTPOOL/$TESTVOL@$TESTSNAP"
export SNAPFS2="$TESTPOOL1/$TESTFS@$TESTSNAP"
export SNAPCTR="$TESTPOOL/$TESTCTR/$TESTFS1@$TESTSNAP"
export SNAPDIR="$TESTDIR/$SNAPROOT/$TESTSNAP"
export SNAPDIR1="$TESTDIR1/$SNAPROOT/$TESTSNAP"
export SNAPDIR2="$TESTDIR2/$SNAPROOT/$TESTSNAP"
export SNAPDIR3="/$SNAPFS1"
export VOLSIZE=1gb
export BLOCKSZ=8192
export NUM_WRITES=20
export DATA=0
export LIMIT=524288 # tolerance measured in bytes, 512K
export FSQUOTA=500m
export FILESIZE=400m
export FILESIZE1=200m
@@ -0,0 +1,91 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# A zfs file system snapshot is identical to
# the originally snapshot'd file system, after the file
# system has been changed. Uses 'sum -r'.
#
# STRATEGY:
# 1. Create a file in the zfs file system
# 2. Checksum the file for later comparison
# 3. Create a snapshot of the dataset
# 4. Append to the original file
# 5. Verify the snapshot and file agree
#
verify_runnable "both"
function cleanup
{
snapexists $SNAPFS
if [[ $? -eq 0 ]]; then
log_must $ZFS destroy $SNAPFS
fi
if [[ -e $SNAPDIR ]]; then
log_must $RM -rf $SNAPDIR > /dev/null 2>&1
fi
if [[ -e $TESTDIR ]]; then
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
fi
}
log_assert "Verify a file system snapshot is identical to original."
log_onexit cleanup
log_note "Create a file in the zfs filesystem..."
log_must $FILE_WRITE -o create -f $TESTDIR/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
log_note "Sum the file, save for later comparison..."
FILE_SUM=`$SUM -r $TESTDIR/$TESTFILE | $AWK '{ print $1 }'`
log_note "FILE_SUM = $FILE_SUM"
log_note "Create a snapshot and mount it..."
log_must $ZFS snapshot $SNAPFS
log_note "Append to the original file..."
log_must $FILE_WRITE -o append -f $TESTDIR/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
SNAP_FILE_SUM=`$SUM -r $SNAPDIR/$TESTFILE | $AWK '{ print $1 }'`
if [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then
log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)"
fi
log_pass "Both Sums match. ($SNAP_FILE_SUM == $FILE_SUM)"
@@ -0,0 +1,134 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# An archive of a zfs file system and an archive of its snapshot
# is identical even though the original file system has
# changed sinced the snapshot was taken.
#
# STRATEGY:
# 1) Create files in all of the zfs file systems
# 2) Create a tarball of the file system
# 3) Create a snapshot of the dataset
# 4) Remove all the files in the original file system
# 5) Create a tarball of the snapshot
# 6) Extract each tarball and compare directory structures
#
verify_runnable "both"
function cleanup
{
if [[ -d $CWD ]]; then
cd $CWD || log_fail "Could not cd $CWD"
fi
snapexists $SNAPFS
if [[ $? -eq 0 ]]; then
log_must $ZFS destroy $SNAPFS
fi
if [[ -e $SNAPDIR ]]; then
log_must $RM -rf $SNAPDIR > /dev/null 2>&1
fi
if [[ -e $TESTDIR ]]; then
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
fi
if [[ -e /tmp/zfs_snapshot2.$$ ]]; then
log_must $RM -rf /tmp/zfs_snapshot2.$$ > /dev/null 2>&1
fi
}
log_assert "Verify an archive of a file system is identical to " \
"an archive of its snapshot."
log_onexit cleanup
typeset -i COUNT=21
typeset OP=create
[[ -n $TESTDIR ]] && \
$RM -rf $TESTDIR/* > /dev/null 2>&1
log_note "Create files in the zfs filesystem..."
typeset i=1
while [ $i -lt $COUNT ]; do
log_must $FILE_WRITE -o $OP -f $TESTDIR/file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $DATA
(( i = i + 1 ))
done
log_note "Create a tarball from $TESTDIR contents..."
CWD=$PWD
cd $TESTDIR || log_fail "Could not cd $TESTDIR"
log_must $TAR cf $TESTDIR/tarball.original.tar file*
cd $CWD || log_fail "Could not cd $CWD"
log_note "Create a snapshot and mount it..."
log_must $ZFS snapshot $SNAPFS
log_note "Remove all of the original files..."
log_must $RM -f $TESTDIR/file* > /dev/null 2>&1
log_note "Create tarball of snapshot..."
CWD=$PWD
cd $SNAPDIR || log_fail "Could not cd $SNAPDIR"
log_must $TAR cf $TESTDIR/tarball.snapshot.tar file*
cd $CWD || log_fail "Could not cd $CWD"
log_must $MKDIR $TESTDIR/original
log_must $MKDIR $TESTDIR/snapshot
CWD=$PWD
cd $TESTDIR/original || log_fail "Could not cd $TESTDIR/original"
log_must $TAR xf $TESTDIR/tarball.original.tar
cd $TESTDIR/snapshot || log_fail "Could not cd $TESTDIR/snapshot"
log_must $TAR xf $TESTDIR/tarball.snapshot.tar
cd $CWD || log_fail "Could not cd $CWD"
$DIRCMP $TESTDIR/original $TESTDIR/snapshot > /tmp/zfs_snapshot2.$$
$GREP different /tmp/zfs_snapshot2.$$ >/dev/null 2>&1
if [[ $? -ne 1 ]]; then
log_fail "Directory structures differ."
fi
log_pass "Directory structures match."
@@ -0,0 +1,103 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify that many snapshots can be made on a zfs file system.
#
# STRATEGY:
# 1) Create a files in the zfs file system
# 2) Create a snapshot of the dataset
# 3) Remove all the files from the original file system
# 4) Verify consistency of each snapshot directory
#
verify_runnable "both"
function cleanup
{
typeset -i i=1
while [ $i -lt $COUNT ]; do
snapexists $SNAPFS.$i
if [[ $? -eq 0 ]]; then
log_must $ZFS destroy $SNAPFS.$i
fi
if [[ -e $SNAPDIR.$i ]]; then
log_must $RM -rf $SNAPDIR.$i > /dev/null 2>&1
fi
(( i = i + 1 ))
done
if [[ -e $TESTDIR ]]; then
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
fi
}
log_assert "Verify many snapshots of a file system can be taken."
log_onexit cleanup
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
log_note "Create some files in the $TESTDIR directory..."
typeset -i i=1
while [[ $i -lt $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
log_must $ZFS snapshot $SNAPFS.$i
(( i = i + 1 ))
done
log_note "Remove all of the original files"
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/file* > /dev/null 2>&1
i=1
while [[ $i -lt $COUNT ]]; do
FILECOUNT=`$LS $SNAPDIR.$i/file* | wc -l`
typeset j=1
while [ $j -lt $FILECOUNT ]; do
log_must $FILE_CHECK $SNAPDIR.$i/file$j $j
(( j = j + 1 ))
done
(( i = i + 1 ))
done
log_pass "All files are consistent"
@@ -0,0 +1,90 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Create a null snapshot i.e. a snapshot created before file system
# activity is empty.
#
# STRATEGY:
# 1. Empty a file system
# 2. Take a snapshot of the empty file system.
# 3. Populate the file system
# 4. Verify the snapshot is still empty
#
verify_runnable "both"
function cleanup
{
snapexists $SNAPFS
[[ $? -eq 0 ]] && \
log_must $ZFS destroy $SNAPFS
[[ -e $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
}
log_assert "Verify that a snapshot of an empty file system remains empty."
log_onexit cleanup
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
log_must $ZFS snapshot $SNAPFS
FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total 0" | wc -l`
if [[ $FILE_COUNT -ne 0 ]]; then
$LS $SNAPDIR
log_fail "BEFORE: $SNAPDIR contains $FILE_COUNT files(s)."
fi
typeset -i COUNT=10
log_note "Populate the $TESTDIR directory"
typeset -i i=1
while [[ $i -lt $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total 0" | wc -l`
if [[ $FILE_COUNT -ne 0 ]]; then
$LS $SNAPDIR
log_fail "AFTER: $SNAPDIR contains $FILE_COUNT files(s)."
fi
log_pass "The NULL snapshot remains empty."
@@ -0,0 +1,90 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# to the originally snapshot'd file system, after the file
# system has been changed. Uses 'sum -r'.
#
# STRATEGY:
# 1) Create a file in the zfs dataset
# 2) Sum the file for later comparison
# 3) Create a snapshot of the dataset
# 4) Append to the original file
# 5) Verify both checksums match
#
verify_runnable "both"
function cleanup
{
snapexists $SNAPCTR
if [[ $? -eq 0 ]]; then
log_must $ZFS destroy $SNAPCTR
fi
if [[ -e $SNAPDIR1 ]]; then
log_must $RM -rf $SNAPDIR1 > /dev/null 2>&1
fi
if [[ -e $TESTDIR ]]; then
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
fi
}
log_assert "Verify that a snapshot of a dataset is identical to " \
"the original dataset."
log_onexit cleanup
log_note "Create a file in the zfs filesystem..."
log_must $FILE_WRITE -o create -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
log_note "Sum the file, save for later comparison..."
FILE_SUM=`$SUM -r $TESTDIR1/$TESTFILE | $AWK '{ print $1 }'`
log_note "FILE_SUM = $FILE_SUM"
log_note "Create a snapshot and mount it..."
log_must $ZFS snapshot $SNAPCTR
log_note "Append to the original file..."
log_must $FILE_WRITE -o append -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
SNAP_FILE_SUM=`$SUM -r $SNAPDIR1/$TESTFILE | $AWK '{ print $1 }'`
if [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then
log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)"
fi
log_pass "Both Sums match. ($SNAP_FILE_SUM == $FILE_SUM)"
@@ -0,0 +1,132 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# An archive of a zfs dataset and an archive of its snapshot
# changed sinced the snapshot was taken.
#
# STRATEGY:
# 1) Create some files in a ZFS dataset
# 2) Create a tarball of the dataset
# 3) Create a snapshot of the dataset
# 4) Remove all the files in the original dataset
# 5) Create a tarball of the snapshot
# 6) Extract each tarball and compare directory structures
#
verify_runnable "both"
function cleanup
{
if [[ -d $CWD ]]; then
cd $CWD || log_fail "Could not cd $CWD"
fi
snapexists $SNAPCTR
if [[ $? -eq 0 ]]; then
log_must $ZFS destroy $SNAPCTR
fi
if [[ -e $SNAPDIR1 ]]; then
log_must $RM -rf $SNAPDIR1 > /dev/null 2>&1
fi
if [[ -e $TESTDIR1 ]]; then
log_must $RM -rf $TESTDIR1/* > /dev/null 2>&1
fi
if [[ -e /tmp/zfs_snapshot2.$$ ]]; then
log_must $RM -rf /tmp/zfs_snapshot2.$$ > /dev/null 2>&1
fi
}
log_assert "Verify that an archive of a dataset is identical to " \
"an archive of the dataset's snapshot."
log_onexit cleanup
typeset -i COUNT=21
typeset OP=create
[[ -n $TESTDIR1 ]] && $RM -rf $TESTDIR1/* > /dev/null 2>&1
log_note "Create files in the zfs dataset ..."
typeset i=1
while [ $i -lt $COUNT ]; do
log_must $FILE_WRITE -o $OP -f $TESTDIR1/file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $DATA
(( i = i + 1 ))
done
log_note "Create a tarball from $TESTDIR1 contents..."
CWD=$PWD
cd $TESTDIR1 || log_fail "Could not cd $TESTDIR1"
log_must $TAR cf $TESTDIR1/tarball.original.tar file*
cd $CWD || log_fail "Could not cd $CWD"
log_note "Create a snapshot and mount it..."
log_must $ZFS snapshot $SNAPCTR
log_note "Remove all of the original files..."
log_must $RM -f $TESTDIR1/file* > /dev/null 2>&1
log_note "Create tarball of snapshot..."
CWD=$PWD
cd $SNAPDIR1 || log_fail "Could not cd $SNAPDIR1"
log_must $TAR cf $TESTDIR1/tarball.snapshot.tar file*
cd $CWD || log_fail "Could not cd $CWD"
log_must $MKDIR $TESTDIR1/original
log_must $MKDIR $TESTDIR1/snapshot
CWD=$PWD
cd $TESTDIR1/original || log_fail "Could not cd $TESTDIR1/original"
log_must $TAR xf $TESTDIR1/tarball.original.tar
cd $TESTDIR1/snapshot || log_fail "Could not cd $TESTDIR1/snapshot"
log_must $TAR xf $TESTDIR1/tarball.snapshot.tar
cd $CWD || log_fail "Could not cd $CWD"
$DIRCMP $TESTDIR1/original $TESTDIR1/snapshot > /tmp/zfs_snapshot2.$$
$GREP different /tmp/zfs_snapshot2.$$ >/dev/null 2>&1
if [[ $? -ne 1 ]]; then
log_fail "Directory structures differ."
fi
log_pass "Directory structures match."
@@ -0,0 +1,107 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify that many snapshots can be made on a zfs dataset.
#
# STRATEGY:
# 1) Create a file in the zfs dataset
# 2) Create a snapshot of the dataset
# 3) Remove all the files from the original dataset
# 4) For each snapshot directory verify consistency
#
verify_runnable "both"
function cleanup
{
typeset -i i=1
while [ $i -lt $COUNT ]; do
snapexists $SNAPCTR.$i
if [[ $? -eq 0 ]]; then
log_must $ZFS destroy $SNAPCTR.$i
fi
if [[ -e $SNAPDIR.$i ]]; then
log_must $RM -rf $SNAPDIR1.$i > /dev/null 2>&1
fi
(( i = i + 1 ))
done
if [[ -e $SNAPDIR1 ]]; then
log_must $RM -rf $SNAPDIR1 > /dev/null 2>&1
fi
if [[ -e $TESTDIR ]]; then
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
fi
}
log_assert "Verify that many snapshots can be made on a zfs dataset."
log_onexit cleanup
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
log_note "Create some files in the $TESTDIR directory..."
typeset -i i=1
while [[ $i -lt $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR1/file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
log_must $ZFS snapshot $SNAPCTR.$i
(( i = i + 1 ))
done
log_note "Remove all of the original files"
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR1/file* > /dev/null 2>&1
i=1
while [[ $i -lt $COUNT ]]; do
FILECOUNT=`$LS $SNAPDIR1.$i/file* | wc -l`
typeset j=1
while [ $j -lt $FILECOUNT ]; do
log_must $FILE_CHECK $SNAPDIR1.$i/file$j $j
(( j = j + 1 ))
done
(( i = i + 1 ))
done
log_pass "All files are consistent"
@@ -0,0 +1,100 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify that destroying snapshots returns space to the pool.
#
# STRATEGY:
# 1. Create a file system and populate it while snapshotting.
# 2. Destroy the snapshots and remove the files.
# 3. Verify the space returns to the pool.
#
verify_runnable "both"
function cleanup
{
typeset -i i=1
while [[ $i -lt $COUNT ]]; do
snapexists $SNAPFS.$i
[[ $? -eq 0 ]] && \
log_must $ZFS destroy $SNAPFS.$i
(( i = i + 1 ))
done
[[ -e $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
}
log_assert "Verify that destroying snapshots returns space to the pool."
log_onexit cleanup
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
orig_size=`get_prop available $TESTPOOL`
log_note "Populate the $TESTDIR directory"
typeset -i i=1
while [[ $i -lt $COUNT ]]; do
log_must $FILE_WRITE -o create -f $TESTDIR/file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
log_must $ZFS snapshot $SNAPFS.$i
(( i = i + 1 ))
done
typeset -i i=1
while [[ $i -lt $COUNT ]]; do
log_must rm -rf $TESTDIR/file$i > /dev/null 2>&1
log_must $ZFS destroy $SNAPFS.$i
(( i = i + 1 ))
done
new_size=`get_prop available $TESTPOOL`
typeset -i tolerance=0
(( tolerance = new_size - orig_size))
if (( tolerance > LIMIT )); then
log_fail "Space not freed. ($orig_size != $new_size)"
fi
log_pass "After destroying snapshots, the space is returned to the pool."
@@ -0,0 +1,119 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify 'snapshot -r' and 'destroy -r' can correctly create and destroy
# snapshot tree respectively.
#
# STRATEGY:
# 1. Use the snapshot -r to create snapshot for top level pool
# 2. Verify the children snapshots are created correctly.
# 3. Use destroy -r to destroy the top level snapshot
# 4. Verify that all children snapshots are destroyed too.
#
verify_runnable "both"
function cleanup
{
typeset ds
typeset snap
for ds in $ctr/$TESTVOL1 $ctr/$TESTCLONE; do
datasetexists $ds && \
log_must $ZFS destroy -f $ds
done
for snap in $ctr/$TESTFS1@$TESTSNAP1 \
$snappool $snapvol $snapctr $snapctrvol \
$snapctrclone $snapctrfs
do
snapexists $snap && \
log_must $ZFS destroy -rf $snap
done
}
log_assert "Verify snapshot -r can correctly create a snapshot tree."
log_onexit cleanup
ctr=$TESTPOOL/$TESTCTR
ctrfs=$ctr/$TESTFS1
ctrclone=$ctr/$TESTCLONE
ctrvol=$ctr/$TESTVOL1
snappool=$SNAPPOOL
snapfs=$SNAPFS
snapctr=$ctr@$TESTSNAP
snapvol=$SNAPFS1
snapctrvol=$ctrvol@$TESTSNAP
snapctrclone=$ctrclone@$TESTSNAP
snapctrfs=$SNAPCTR
#preparation for testing
log_must $ZFS snapshot $ctrfs@$TESTSNAP1
log_must $ZFS clone $ctrfs@$TESTSNAP1 $ctrclone
if is_global_zone; then
log_must $ZFS create -V $VOLSIZE $ctrvol
else
log_must $ZFS create $ctrvol
fi
log_must $ZFS snapshot -r $snappool
#verify the snapshot -r results
for snap in $snappool $snapfs $snapvol $snapctr $snapctrvol \
$snapctrclone $snapctrfs
do
! snapexists $snap && \
log_fail "The snapshot $snap is not created via -r option."
done
log_note "Verify that destroy -r can destroy the snapshot tree."
log_must $ZFS destroy -r $snappool
for snap in $snappool $snapfs $snapvol $snapctr $snapctrvol \
$snapctrclone $snapctrfs
do
snapexists $snap && \
log_fail "The snapshot $snap is not destroyed correctly."
done
log_note "Verify that the snapshot with different name should \
be not destroyed."
! snapexists $ctrfs@$TESTSNAP1 && \
log_fail "destroy -r incorrectly destroys the snapshot \
$ctrfs@$TESTSNAP1."
log_pass "snapshot|destroy -r with snapshot tree works as expected."
@@ -0,0 +1,101 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify 'destroy -r' can correctly destroy a snapshot tree at any point.
#
# STRATEGY:
# 1. Use the snapshot -r to create snapshot for top level pool
# 2. Select a middle point of the snapshot tree, use destroy -r to destroy all
# snapshots beneath the point.
# 3. Verify the destroy results.
#
verify_runnable "both"
function cleanup
{
typeset snap
datasetexists $ctrvol && \
log_must $ZFS destroy -f $ctrvol
for snap in $ctrfs@$TESTSNAP1 \
$snappool $snapvol $snapctr $snapctrvol \
$snapctrclone $snapctrfs
do
snapexists $snap && \
log_must $ZFS destroy -rf $snap
done
}
log_assert "Verify 'destroy -r' can correctly destroy a snapshot subtree at any point."
log_onexit cleanup
ctr=$TESTPOOL/$TESTCTR
ctrfs=$ctr/$TESTFS1
ctrvol=$ctr/$TESTVOL1
snappool=$SNAPPOOL
snapfs=$SNAPFS
snapctr=$ctr@$TESTSNAP
snapvol=$SNAPFS1
snapctrvol=$ctr/$TESTVOL1@$TESTSNAP
snapctrclone=$ctr/$TESTCLONE@$TESTSNAP
snapctrfs=$SNAPCTR
#preparation for testing
log_must $ZFS snapshot $ctrfs@$TESTSNAP1
if is_global_zone; then
log_must $ZFS create -V $VOLSIZE $ctrvol
else
log_must $ZFS create $ctrvol
fi
log_must $ZFS snapshot -r $snappool
#select the $TESTCTR as destroy point, $TESTCTR is a child of $TESTPOOL
log_must $ZFS destroy -r $snapctr
for snap in $snapctr $snapctrvol $snapctrclone $snapctrfs; do
snapexists $snap && \
log_fail "The snapshot $snap is not destroyed correctly."
done
for snap in $snappool $snapfs $snapvol $ctrfs@$TESTSNAP1;do
! snapexists $snap && \
log_fail "The snapshot $snap should be not destroyed."
done
log_pass "'destroy -r' destroys snapshot subtree as expected."
@@ -0,0 +1,113 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# use 'snapshot -r' to create a snapshot tree, add some files to one child
# filesystem, rollback the child filesystem snapshot, verify that the child
# filesystem gets back to the status while taking the snapshot.
#
# STRATEGY:
# 1. Add some files to a target child filesystem
# 2. snapshot -r the parent filesystem
# 3. Add some other files to the target child filesystem
# 4. rollback the child filesystem snapshot
# 5. verify that the child filesystem get back to the status while being
# snapshot'd
#
verify_runnable "both"
function cleanup
{
snapexists $SNAPPOOL && \
log_must $ZFS destroy -r $SNAPPOOL
[[ -e $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
}
log_assert "Verify that rollback to a snapshot created by snapshot -r succeeds."
log_onexit cleanup
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
log_note "Populate the $TESTDIR directory (prior to snapshot)"
typeset -i i=0
while (( i < COUNT )); do
log_must $FILE_WRITE -o create -f $TESTDIR/before_file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
log_must $ZFS snapshot -r $SNAPPOOL
FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
if (( FILE_COUNT != COUNT )); then
$LS -Al $SNAPDIR
log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)."
fi
log_note "Populate the $TESTDIR directory (post snapshot)"
typeset -i i=0
while (( i < COUNT )); do
log_must $FILE_WRITE -o create -f $TESTDIR/after_file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
#
# Now rollback to latest snapshot
#
log_must $ZFS rollback $SNAPFS
FILE_COUNT=`$LS -Al $TESTDIR/after* 2> /dev/null | $GREP -v "total" | wc -l`
if (( FILE_COUNT != 0 )); then
$LS -Al $TESTDIR
log_fail "$TESTDIR contains $FILE_COUNT after* files(s)."
fi
FILE_COUNT=`$LS -Al $TESTDIR/before* 2> /dev/null \
| $GREP -v "total" | wc -l`
if (( FILE_COUNT != $COUNT )); then
$LS -Al $TESTDIR
log_fail "$TESTDIR contains $FILE_COUNT before* files(s)."
fi
log_pass "Rollback with child snapshot works as expected."
@@ -0,0 +1,104 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify 'snapshot -r' can create snapshot for promoted clone, and vice
# versa, a clone filesystem from the snapshot created by 'snapshot -r'
# can be correctly promoted.
#
# STRATEGY:
# 1. Create a dataset tree
# 2. snapshot a filesystem and clone the snapshot
# 3. promote the clone
# 4. snapshot -r the dataset tree
# 5. verify that the snapshot of cloned filesystem is created correctly
# 6. clone a snapshot from the snapshot tree
# 7. promote the clone
# 8. verify that the clone is promoted correctly.
#
verify_runnable "both"
function cleanup
{
if datasetexists $clone1; then
log_must $ZFS promote $ctrfs
log_must $ZFS destroy $clone1
fi
snapexists $snapctr && \
log_must $ZFS destroy -r $snapctr
if snapexists $clone@$TESTSNAP1; then
log_must $ZFS promote $ctrfs
log_must $ZFS destroy -rR $ctrfs@$TESTSNAP1
fi
}
log_assert "Verify that 'snapshot -r' can work with 'zfs promote'."
log_onexit cleanup
ctr=$TESTPOOL/$TESTCTR
ctrfs=$ctr/$TESTFS1
clone=$ctr/$TESTCLONE
clone1=$ctr/$TESTCLONE1
snappool=$SNAPPOOL
snapfs=$SNAPFS
snapctr=$ctr@$TESTSNAP
snapctrclone=$clone@$TESTSNAP
snapctrclone1=$clone1@$TESTSNAP
snapctrfs=$SNAPCTR
#preparation for testing
log_must $ZFS snapshot $ctrfs@$TESTSNAP1
log_must $ZFS clone $ctrfs@$TESTSNAP1 $clone
log_must $ZFS promote $clone
log_must $ZFS snapshot -r $snapctr
! snapexists $snapctrclone && \
log_fail "'snapshot -r' fails to create $snapctrclone for $ctr/$TESTCLONE."
log_must $ZFS clone $snapctrfs $clone1
log_must $ZFS promote $clone1
#verify the origin value is correct.
orig_value=$(get_prop origin $ctrfs)
if ! snapexists $snapctrclone1 || [[ "$orig_value" != "$snapctrclone1" ]]; then
log_fail "'zfs promote' fails to promote $clone which is cloned from \
$snapctrfs."
fi
log_pass "'snapshot -r' can work with 'zfs promote' as expected."
@@ -0,0 +1,99 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# verify that the snapshots created by 'snapshot -r' can be used for
# zfs send/recv
#
# STRATEGY:
# 1. create a dataset tree and populate a filesystem
# 2. snapshot -r the dataset tree
# 3. select one snapshot used for zfs send/recv
# 4. verify the data integrity after zfs send/recv
#
verify_runnable "both"
function cleanup
{
datasetexists $ctrfs && \
$ZFS destroy -r $ctrfs
snapexists $snappool && \
log_must $ZFS destroy -r $snappool
[[ -e $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
}
log_assert "Verify snapshots from 'snapshot -r' can be used for zfs send/recv"
log_onexit cleanup
ctr=$TESTPOOL/$TESTCTR
ctrfs=$ctr/$TESTFS
snappool=$SNAPPOOL
snapfs=$SNAPFS
snapctr=$ctr@$TESTSNAP
snapctrfs=$ctrfs@$TESTSNAP
fsdir=/$ctrfs
snapdir=$fsdir/.zfs/snapshot/$TESTSNAP
[[ -n $TESTDIR ]] && \
log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
typeset -i COUNT=10
log_note "Populate the $TESTDIR directory (prior to snapshot)"
typeset -i i=0
while (( i < COUNT )); do
log_must $FILE_WRITE -o create -f $TESTDIR/file$i \
-b $BLOCKSZ -c $NUM_WRITES -d $i
(( i = i + 1 ))
done
log_must $ZFS snapshot -r $snappool
$ZFS send $snapfs | $ZFS receive $ctrfs >/dev/null 2>&1
if ! datasetexists $ctrfs || ! snapexists $snapctrfs; then
log_fail "zfs send/receive fails with snapshot $snapfs."
fi
for dir in $fsdir $snapdir; do
FILE_COUNT=`$LS -Al $dir | $GREP -v "total" | wc -l`
(( FILE_COUNT != COUNT )) && log_fail "Got $FILE_COUNT expected $COUNT"
done
log_pass "'zfs send/receive' works as expected with snapshots from 'snapshot -r'"
@@ -0,0 +1,78 @@
#! /bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# verify that creating/destroying snapshots do things clean
#
# STRATEGY:
# 1. create a dataset and set a quota with 500m
# 2. create file of size 400m on the dataset
# 3. take a snapshot and destroy it
# 4. then create file to use all spaces in the dataset
# 5. verify removing the first file should succeed
#
verify_runnable "both"
function cleanup
{
[[ -e $TESTDIR1 ]] && \
log_must $RM -rf $TESTDIR1/* > /dev/null 2>&1
snapexists $SNAPCTR && \
log_must $ZFS destroy $SNAPCTR
datasetexists $TESTPOOL/$TESTCTR/$TESTFS1 && \
log_must $ZFS set quota=none $TESTPOOL/$TESTCTR/$TESTFS1
}
log_assert "Verify creating/destroying snapshots do things clean"
log_onexit cleanup
log_must $ZFS set quota=$FSQUOTA $TESTPOOL/$TESTCTR/$TESTFS1
log_must $MKFILE $FILESIZE $TESTDIR1/$TESTFILE
log_must $ZFS snapshot $SNAPCTR
log_must $ZFS destroy $SNAPCTR
log_note "Make the quota of filesystem is reached"
log_mustnot $MKFILE $FILESIZE1 $TESTDIR1/$TESTFILE1
log_note "Verify removing the first file should succeed after the snapshot is \
removed"
log_must $RM $TESTDIR1/$TESTFILE
log_pass "Verify creating/destroying snapshots do things clean"
@@ -0,0 +1,121 @@
#!/bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
. $STF_SUITE/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib
#
# DESCRIPTION:
# Verify snapshot can be created or destroy via mkdir or rm
# in .zfs/snapshot.
#
# STRATEGY:
# 1. Verify make directories only successfully in .zfs/snapshot.
# 2. Verify snapshot can be created and destroy via mkdir and remove
# directories in .zfs/snapshot.
# 3. Verify rollback to previous snapshot can succeed.
# 4. Verify remove directory in snapdir can destroy snapshot.
#
verify_runnable "both"
function cleanup
{
typeset -i i=0
while ((i < snap_cnt)); do
typeset snap=$fs@snap.$i
datasetexists $snap && log_must $ZFS destroy -f $snap
((i += 1))
done
}
$ZFS 2>&1 | $GREP "allow" > /dev/null
(($? != 0)) && log_unsupported
log_assert "Verify snapshot can be created via mkdir in .zfs/snapshot."
log_onexit cleanup
fs=$TESTPOOL/$TESTFS
# Verify all the other directories are readonly.
mntpnt=$(get_prop mountpoint $fs)
snapdir=$mntpnt/.zfs
set -A ro_dirs "$snapdir" "$snapdir/snap" "$snapdir/snapshot"
for dir in ${ro_dirs[@]}; do
if [[ -d $dir ]]; then
log_mustnot $RM -rf $dir
log_mustnot $TOUCH $dir/testfile
else
log_mustnot $MKDIR $dir
fi
done
# Verify snapshot can be created via mkdir in .zfs/snapshot
typeset -i snap_cnt=5
typeset -i cnt=0
while ((cnt < snap_cnt)); do
testfile=$mntpnt/testfile.$cnt
log_must $MKFILE 1M $testfile
log_must $MKDIR $snapdir/snapshot/snap.$cnt
if ! datasetexists $fs@snap.$cnt ; then
log_fail "ERROR: $fs@snap.$cnt should exists."
fi
((cnt += 1))
done
# Verify rollback to previous snapshot succeed.
((cnt = RANDOM % snap_cnt))
log_must $ZFS rollback -r $fs@snap.$cnt
typeset -i i=0
while ((i < snap_cnt)); do
testfile=$mntpnt/testfile.$i
if ((i <= cnt)); then
if [[ ! -f $testfile ]]; then
log_fail "ERROR: $testfile should exists."
fi
else
if [[ -f $testfile ]]; then
log_fail "ERROR: $testfile should not exists."
fi
fi
((i += 1))
done
# Verify remove directory in snapdir can destroy snapshot.
log_must $RMDIR $snapdir/snapshot/snap.$cnt
log_mustnot datasetexists $fs@snap.$cnt
log_pass "Verify snapshot can be created via mkdir in .zfs/snapshot passed."
@@ -0,0 +1,101 @@
#!/bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify renamed snapshots via mv can be destroyed
#
# STRATEGY:
# 1. Create snapshot
# 2. Rename the snapshot via mv command
# 2. Verify destroying the renamed snapshot via 'zfs destroy' succeeds
#
verify_runnable "both"
function cleanup
{
datasetexists $SNAPFS && \
log_must $ZFS destroy -Rf $SNAPFS
datasetexists $TESTPOOL/$TESTFS@snap_a && \
log_must $ZFS destroy -Rf $TESTPOOL/$TESTFS@snap_a
datasetexists $TESTPOOL/$TESTCLONE@snap_a && \
log_must $ZFS destroy -Rf $TESTPOOL/$TESTCLONE@snap_a
datasetexists $TESTPOOL/$TESTCLONE && \
log_must $ZFS destroy $TESTPOOL/$TESTCLONE
datasetexists $TESTPOOL/$TESTFS && \
log_must $ZFS destroy $TESTPOOL/$TESTFS
log_must $ZFS create $TESTPOOL/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
}
log_assert "Verify renamed snapshots via mv can be destroyed."
log_onexit cleanup
# scenario 1
log_must $ZFS snapshot $SNAPFS
log_must $MV $TESTDIR/$SNAPROOT/$TESTSNAP $TESTDIR/$SNAPROOT/snap_a
datasetexists $TESTPOOL/$TESTFS@snap_a || \
log_fail "rename snapshot via mv in .zfs/snapshot fails."
log_must $ZFS destroy $TESTPOOL/$TESTFS@snap_a
# scenario 2
log_must $ZFS snapshot $SNAPFS
log_must $ZFS clone $SNAPFS $TESTPOOL/$TESTCLONE
log_must $MV $TESTDIR/$SNAPROOT/$TESTSNAP $TESTDIR/$SNAPROOT/snap_a
datasetexists $TESTPOOL/$TESTFS@snap_a || \
log_fail "rename snapshot via mv in .zfs/snapshot fails."
log_must $ZFS promote $TESTPOOL/$TESTCLONE
# promote back to $TESTPOOL/$TESTFS for scenario 3
log_must $ZFS promote $TESTPOOL/$TESTFS
log_must $ZFS destroy $TESTPOOL/$TESTCLONE
log_must $ZFS destroy $TESTPOOL/$TESTFS@snap_a
# scenario 3
log_must $ZFS snapshot $SNAPFS
log_must $ZFS clone $SNAPFS $TESTPOOL/$TESTCLONE
log_must $ZFS rename $SNAPFS $TESTPOOL/$TESTFS@snap_a
log_must $ZFS promote $TESTPOOL/$TESTCLONE
log_must $ZFS destroy $TESTPOOL/$TESTFS
log_must $ZFS destroy $TESTPOOL/$TESTCLONE@snap_a
log_pass "Verify renamed snapshots via mv can be destroyed."
@@ -0,0 +1,202 @@
#!/bin/ksh -p
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
#
# Directory structure of snapshots reflects filesystem structure.
#
# STRATEGY:
#
# This test makes sure that the directory structure of snapshots is
# a proper reflection of the filesystem the snapshot was taken of.
#
# 1. Create a simple directory structure of files and directories
# 2. Take a snapshot of the filesystem
# 3. Modify original filesystem
# 4. Walk down the snapshot directory structure verifying it
# checking with both absolute and relative paths
#
verify_runnable "both"
function cleanup
{
cd $SAVED_DIR
if datasetexists $TESTPOOL/$TESTFS ; then
log_must $ZFS destroy -Rf $TESTPOOL/$TESTFS
fi
log_must $ZFS create $TESTPOOL/$TESTFS
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
}
function verify_structure {
# check absolute paths
DIR=$PWD
verify_file $DIR/file1
verify_file $DIR/file2
verify_file $DIR/dir1/file3
verify_file $DIR/dir1/file4
verify_file $DIR/dir1/dir2/file5
verify_file $DIR/dir1/dir2/file6
verify_no_file $DIR/file99
# check relative paths
verify_file ./file1
verify_file ./file2
verify_file ./dir1/file3
verify_file ./dir1/file4
verify_file ./dir1/dir2/file5
verify_file ./dir1/dir2/file6
cd dir1
verify_file ../file1
verify_file ../file2
verify_file ./file3
verify_file ./file4
verify_no_file ../file99
cd dir2
verify_file ./file5
verify_file ./file6
verify_file ../file3
verify_file ../file4
verify_no_file ../file99
verify_file ../../file1
verify_file ../../file2
verify_no_file ../../file99
}
function verify_file {
if [ ! -e $1 ]
then
log_note "Working dir is $PWD"
log_fail "File $1 does not exist!"
fi
}
function verify_no_file {
if [ -e $1 ]
then
log_note "Working dir is $PWD"
log_fail "File $1 exists when it should not!"
fi
}
function verify_dir {
if [ ! -d $1 ]
then
log_note "Working dir is $PWD"
log_fail "Directory $1 does not exist!"
fi
}
log_assert "Directory structure of snapshots reflects filesystem structure."
log_onexit cleanup
SAVED_DIR=$PWD
#
# Create a directory structure with the following files
#
# ./file1
# ./file2
# ./dir1/file3
# ./dir1/file4
# ./dir1/dir2/file5
# ./dir1/dir2/file6
cd $TESTDIR
$MKFILE 10m file1
$MKFILE 20m file2
$MKDIR dir1
cd dir1
$MKFILE 10m file3
$MKFILE 20m file4
$MKDIR dir2
cd dir2
$MKFILE 10m file5
$MKFILE 20m file6
# Now walk the directory structure verifying it
cd $TESTDIR
verify_structure
# Take snapshots
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap_a
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap_b
# Change the filesystem structure by renaming files in the original structure
# The snapshot file structure should not change
cd $TESTDIR
log_must $MV file2 file99
cd dir1
log_must $MV file4 file99
cd dir2
log_must $MV file6 file99
# verify the top level snapshot directories
verify_dir $TESTDIR/.zfs
verify_dir $TESTDIR/.zfs/snapshot
verify_dir $TESTDIR/.zfs/snapshot/snap_a
verify_dir $TESTDIR/.zfs/snapshot/snap_b
cd $TESTDIR/.zfs/snapshot/snap_a
verify_structure
cd $TESTDIR/.zfs/snapshot/snap_b
verify_structure
cd $TESTDIR/.zfs
verify_dir snapshot
cd $TESTDIR/.zfs/snapshot
verify_dir snap_a
verify_dir snap_b
cd snap_a
verify_dir ../snap_a
verify_dir ../snap_b
cd ..
verify_dir snap_a
verify_dir snap_b
log_pass "Directory structure of snapshots reflects filesystem structure."