f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER START
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# The contents of this file are subject to the terms of the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Common Development and Distribution License (the "License").
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You may not use this file except in compliance with the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# See the License for the specific language governing permissions
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# and limitations under the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER END
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# This setup script is moderately complex, as it creates scenarios for all
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# of the tests included in this directory. Usually we'd want each test case
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# to setup/teardown it's own configuration, but this would be time consuming
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# given the nature of these tests. However, as a side-effect, one test
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# leaving the system in an unknown state could impact other test cases.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Create a default setup that includes a volume
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# The rest of this setup script creates a ZFS filesystem configuration
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# that is used to test the rest of the zfs subcommands in this directory.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# create a snapshot and a clone to test clone promote
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs snapshot $TESTPOOL/$TESTFS@snap
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS/clone
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# create a file in the filesystem that isn't in the above snapshot
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# create a non-default property and a child we can use to test inherit
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs create $TESTPOOL/$TESTFS/$TESTFS2
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs set snapdir=hidden $TESTPOOL/$TESTFS
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# create an unmounted filesystem to test unmount
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs create $TESTPOOL/$TESTFS/$TESTFS2.unmounted
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs unmount $TESTPOOL/$TESTFS/$TESTFS2.unmounted
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# send our snapshot to a known file in /tmp
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyzfs send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.dat
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_fail "ZFS send datafile was not created!"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must chmod 644 /tmp/zfstest_datastream.dat
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# create a filesystem that has particular properties to test set/get
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs create -o version=1 $TESTPOOL/$TESTFS/prop
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs set $prop_name=$prop_val $TESTPOOL/$TESTFS/prop
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# create a filesystem we don't mind renaming
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs create $TESTPOOL/$TESTFS/renameme
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # create a filesystem we can share
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs create $TESTPOOL/$TESTFS/unshared
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs set sharenfs=off $TESTPOOL/$TESTFS/unshared
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # create a filesystem that we can unshare
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs create $TESTPOOL/$TESTFS/shared
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs set sharenfs=on $TESTPOOL/$TESTFS/shared
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs create -o version=1 $TESTPOOL/$TESTFS/version1
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs create -o version=1 $TESTPOOL/$TESTFS/allowed
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs allow everyone create $TESTPOOL/$TESTFS/allowed
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # Now create several virtual disks to test zpool with
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy mkfile $MINVDEVSIZE /$TESTDIR/disk-additional.dat
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy mkfile $MINVDEVSIZE /$TESTDIR/disk-export.dat
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy mkfile $MINVDEVSIZE /$TESTDIR/disk-offline.dat
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy mkfile $MINVDEVSIZE /$TESTDIR/disk-spare1.dat
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy mkfile $MINVDEVSIZE /$TESTDIR/disk-spare2.dat
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # and create a pool we can perform attach remove replace,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # etc. operations with
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zpool create $TESTPOOL.virt mirror /$TESTDIR/disk1.dat \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy /$TESTDIR/disk2.dat /$TESTDIR/disk3.dat /$TESTDIR/disk-offline.dat \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # Offline one of the disks to test online
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zpool offline $TESTPOOL.virt /$TESTDIR/disk-offline.dat
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # create an exported pool to test import
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zpool create $TESTPOOL.exported /$TESTDIR/disk-export.dat
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy typeset -i i=0
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zpool set $prop_name=$prop_val $TESTPOOL
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # copy a v1 pool from cli_root
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy cp $STF_SUITE/tests/functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1.dat.bz2 \
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must bunzip2 /$TESTDIR/zfs-pool-v1.dat.bz2