tests/zfs-tests/cmd/threadsappend/Makefile
tests/zfs-tests/cmd/xattrtest/Makefile
tests/zfs-tests/include/Makefile
+ tests/zfs-tests/include/default.cfg
tests/zfs-tests/tests/Makefile
tests/zfs-tests/tests/functional/Makefile
tests/zfs-tests/tests/functional/acl/Makefile
tests/zfs-tests/tests/functional/ctime/Makefile
tests/zfs-tests/tests/functional/delegate/Makefile
tests/zfs-tests/tests/functional/devices/Makefile
+ tests/zfs-tests/tests/functional/events/Makefile
tests/zfs-tests/tests/functional/exec/Makefile
tests/zfs-tests/tests/functional/fault/Makefile
tests/zfs-tests/tests/functional/features/async_destroy/Makefile
# Check if ksh exists
#
[ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh."
+[ -e "$STF_SUITE/include/default.cfg" ] || fail \
+ "Missing $STF_SUITE/include/default.cfg file."
#
# Verify the ZFS module stack if loaded.
[tests/functional/devices]
tests = ['devices_001_pos', 'devices_002_neg', 'devices_003_pos']
+[tests/functional/events]
+tests = ['events_001_pos', 'events_002_pos']
+
[tests/functional/exec]
tests = ['exec_001_pos', 'exec_002_neg']
--- /dev/null
+/default.cfg
math.shlib \
properties.shlib \
zpool_script.shlib
+
+EXTRA_DIST=default.cfg.in
+
+distclean-local::
+ -$(RM) $(dist_pkgdata_SCRIPTS)
+++ /dev/null
-#
-# 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) 2016 by Delphix. All rights reserved.
-# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
-#
-
-. $STF_SUITE/include/commands.cfg
-. $STF_SUITE/include/libtest.shlib
-
-# ZFS Directories
-export ZEDLETDIR=${ZEDLETDIR:-/etc/zfs/zed.d}
-export ZPOOLSCRIPTDIR=${ZPOOLSCRIPTDIR:-/etc/zfs/zpool.d}
-
-# Define run length constants
-export RT_LONG="3"
-export RT_MEDIUM="2"
-export RT_SHORT="1"
-
-# Define macro for zone test
-export ZONE_POOL="zonepool"
-export ZONE_CTR="zonectr"
-
-# ensure we're running in the C locale, since
-# localised messages may result in test failures
-export LC_ALL="C"
-export LANG="C"
-
-#
-# pattern to ignore from 'zpool list'.
-#
-export NO_POOLS="no pools available"
-
-# pattern to ignore from 'zfs list'.
-export NO_DATASETS="no datasets available"
-
-export TEST_BASE_DIR="/var/tmp"
-
-# Default to compression ON
-export COMPRESSION_PROP=on
-
-# Default to using the checksum
-export CHECKSUM_PROP=on
-
-# some common variables used by test scripts :
-export FIO_SCRIPTS=$STF_SUITE/tests/perf/fio
-export PERF_SCRIPTS=$STF_SUITE/tests/perf/scripts
-
-# some test pool names
-export TESTPOOL=testpool
-export TESTPOOL1=testpool1
-export TESTPOOL2=testpool2
-export TESTPOOL3=testpool3
-export PERFPOOL=perfpool
-
-# some test file system names
-export TESTFS=testfs
-export TESTFS1=testfs1
-export TESTFS2=testfs2
-export TESTFS3=testfs3
-
-# some test directory names
-export TESTDIR=${TEST_BASE_DIR%%/}/testdir
-export TESTDIR0=${TEST_BASE_DIR%%/}/testdir0
-export TESTDIR1=${TEST_BASE_DIR%%/}/testdir1
-export TESTDIR2=${TEST_BASE_DIR%%/}/testdir2
-
-# some test sub file system names
-export TESTSUBFS=subfs
-export TESTSUBFS1=subfs1
-export TESTSUBFS2=subfs2
-
-# some temp files
-export TEMPFILE=${TEST_BASE_DIR%%/}/tempfile$$
-export TEMPFILE0=${TEST_BASE_DIR%%/}/tempfile0$$
-export TEMPFILE1=${TEST_BASE_DIR%%/}/tempfile1$$
-export TEMPFILE2=${TEST_BASE_DIR%%/}/tempfile2$$
-
-export ZFSROOT=
-
-export TESTSNAP=testsnap
-export TESTSNAP1=testsnap1
-export TESTSNAP2=testsnap2
-export TESTCLONE=testclone
-export TESTCLONE1=testclone1
-export TESTCLONE2=testclone2
-export TESTCLCT=testclct
-export TESTCTR=testctr
-export TESTCTR1=testctr1
-export TESTCTR2=testctr2
-export TESTVOL=testvol
-export TESTVOL1=testvol1
-export TESTVOL2=testvol2
-export TESTFILE0=testfile0
-export TESTFILE1=testfile1
-export TESTFILE2=testfile2
-export TESTBKMARK=testbkmark
-
-export LONGPNAME="poolname50charslong_012345678901234567890123456789"
-export LONGFSNAME="fsysname50charslong_012345678901234567890123456789"
-export SNAPFS="$TESTPOOL/$TESTFS@$TESTSNAP"
-export SNAPFS1="$TESTPOOL/$TESTVOL@$TESTSNAP"
-
-export VOLSIZE=150m
-export BIGVOLSIZE=1eb
-
-# Default to limit disks to be checked
-export MAX_FINDDISKSNUM=6
-
-# Default minimum size for file based vdevs in the test suite
-export MINVDEVSIZE=$((256 * 1024 * 1024))
-
-# Minimum vdev size possible as defined in the OS
-export SPA_MINDEVSIZE=$((64 * 1024 * 1024))
-
-# For iscsi target support
-export ISCSITGTFILE=/tmp/iscsitgt_file
-export ISCSITGT_FMRI=svc:/system/iscsitgt:default
-if ! is_linux; then
-export AUTO_SNAP=$(svcs -a | grep auto-snapshot | grep online | awk \
- '{print $3}')
-fi
-
-#
-# finally, if we're running in a local zone
-# we take some additional actions
-if ! is_global_zone; then
- reexport_pool
-fi
-
-export ZFS_VERSION=5
-export ZFS_ALL_VERSIONS="1 2 3 4 5"
-
-for i in $ZFS_ALL_VERSIONS; do
- eval 'export ZFS_VERSION_$i="v${i}-fs"'
-done
-
-export MAX_PARTITIONS=8
-
-if is_linux; then
- unpack_opts="--sparse -xf"
- pack_opts="--sparse -cf"
- verbose=" -v"
- unpack_preserve=" -xpf"
- pack_preserve=" -cpf"
-
- ZVOL_DEVDIR="/dev/zvol"
- ZVOL_RDEVDIR="/dev/zvol"
- DEV_RDSKDIR="/dev"
- DEV_MPATHDIR="/dev/mapper"
-
- ZEDLET_DIR="/var/tmp/zed"
- VDEVID_CONF="$ZEDLET_DIR/vdev_id.conf"
- VDEVID_CONF_ETC="/etc/zfs/vdev_id.conf"
-
-
- NEWFS_DEFAULT_FS="ext2"
-else
- unpack_opts="xv"
- pack_opts="cf"
- verbose="v"
- unpack_preserve="xpf"
- pack_preserve="cpf"
-
- ZVOL_DEVDIR="/dev/zvol/dsk"
- ZVOL_RDEVDIR="/dev/zvol/rdsk"
- DEV_DSKDIR="/dev/dsk"
- DEV_RDSKDIR="/dev/rdsk"
-
- NEWFS_DEFAULT_FS="ufs"
-fi
-export unpack_opts pack_opts verbose unpack_preserve pack_preserve \
- ZVOL_DEVDIR ZVOL_RDEVDIR NEWFS_DEFAULT_FS DEV_RDSKDIR DEV_MPATHDIR \
- ZEDLET_DIR VDEVID_CONF VDEVID_CONF_ETC
--- /dev/null
+#
+# 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) 2016 by Delphix. All rights reserved.
+# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
+#
+
+. $STF_SUITE/include/commands.cfg
+. $STF_SUITE/include/libtest.shlib
+
+# ZFS Directories
+export prefix=@prefix@
+export exec_prefix=@exec_prefix@
+export ZEDLET_ETC_DIR=${ZEDLET_ETC_DIR:-@sysconfdir@/zfs/zed.d}
+export ZEDLET_LIBEXEC_DIR=${ZEDLET_LIBEXEC_DIR:-@libexecdir@/zfs/zed.d}
+export ZPOOL_SCRIPT_DIR=${ZPOOL_SCRIPT_DIR:-@sysconfdir@/zfs/zpool.d}
+
+# Define run length constants
+export RT_LONG="3"
+export RT_MEDIUM="2"
+export RT_SHORT="1"
+
+# Define macro for zone test
+export ZONE_POOL="zonepool"
+export ZONE_CTR="zonectr"
+
+# ensure we're running in the C locale, since
+# localised messages may result in test failures
+export LC_ALL="C"
+export LANG="C"
+
+#
+# pattern to ignore from 'zpool list'.
+#
+export NO_POOLS="no pools available"
+
+# pattern to ignore from 'zfs list'.
+export NO_DATASETS="no datasets available"
+
+export TEST_BASE_DIR="/var/tmp"
+
+# Default to compression ON
+export COMPRESSION_PROP=on
+
+# Default to using the checksum
+export CHECKSUM_PROP=on
+
+# some common variables used by test scripts :
+export FIO_SCRIPTS=$STF_SUITE/tests/perf/fio
+export PERF_SCRIPTS=$STF_SUITE/tests/perf/scripts
+
+# some test pool names
+export TESTPOOL=testpool
+export TESTPOOL1=testpool1
+export TESTPOOL2=testpool2
+export TESTPOOL3=testpool3
+export PERFPOOL=perfpool
+
+# some test file system names
+export TESTFS=testfs
+export TESTFS1=testfs1
+export TESTFS2=testfs2
+export TESTFS3=testfs3
+
+# some test directory names
+export TESTDIR=${TEST_BASE_DIR%%/}/testdir
+export TESTDIR0=${TEST_BASE_DIR%%/}/testdir0
+export TESTDIR1=${TEST_BASE_DIR%%/}/testdir1
+export TESTDIR2=${TEST_BASE_DIR%%/}/testdir2
+
+# some test sub file system names
+export TESTSUBFS=subfs
+export TESTSUBFS1=subfs1
+export TESTSUBFS2=subfs2
+
+# some temp files
+export TEMPFILE=${TEST_BASE_DIR%%/}/tempfile$$
+export TEMPFILE0=${TEST_BASE_DIR%%/}/tempfile0$$
+export TEMPFILE1=${TEST_BASE_DIR%%/}/tempfile1$$
+export TEMPFILE2=${TEST_BASE_DIR%%/}/tempfile2$$
+
+export ZFSROOT=
+
+export TESTSNAP=testsnap
+export TESTSNAP1=testsnap1
+export TESTSNAP2=testsnap2
+export TESTCLONE=testclone
+export TESTCLONE1=testclone1
+export TESTCLONE2=testclone2
+export TESTCLCT=testclct
+export TESTCTR=testctr
+export TESTCTR1=testctr1
+export TESTCTR2=testctr2
+export TESTVOL=testvol
+export TESTVOL1=testvol1
+export TESTVOL2=testvol2
+export TESTFILE0=testfile0
+export TESTFILE1=testfile1
+export TESTFILE2=testfile2
+export TESTBKMARK=testbkmark
+
+export LONGPNAME="poolname50charslong_012345678901234567890123456789"
+export LONGFSNAME="fsysname50charslong_012345678901234567890123456789"
+export SNAPFS="$TESTPOOL/$TESTFS@$TESTSNAP"
+export SNAPFS1="$TESTPOOL/$TESTVOL@$TESTSNAP"
+
+export VOLSIZE=150m
+export BIGVOLSIZE=1eb
+
+# Default to limit disks to be checked
+export MAX_FINDDISKSNUM=6
+
+# Default minimum size for file based vdevs in the test suite
+export MINVDEVSIZE=$((256 * 1024 * 1024))
+
+# Minimum vdev size possible as defined in the OS
+export SPA_MINDEVSIZE=$((64 * 1024 * 1024))
+
+# For iscsi target support
+export ISCSITGTFILE=/tmp/iscsitgt_file
+export ISCSITGT_FMRI=svc:/system/iscsitgt:default
+if ! is_linux; then
+export AUTO_SNAP=$(svcs -a | grep auto-snapshot | grep online | awk \
+ '{print $3}')
+fi
+
+#
+# finally, if we're running in a local zone
+# we take some additional actions
+if ! is_global_zone; then
+ reexport_pool
+fi
+
+export ZFS_VERSION=5
+export ZFS_ALL_VERSIONS="1 2 3 4 5"
+
+for i in $ZFS_ALL_VERSIONS; do
+ eval 'export ZFS_VERSION_$i="v${i}-fs"'
+done
+
+export MAX_PARTITIONS=8
+
+if is_linux; then
+ unpack_opts="--sparse -xf"
+ pack_opts="--sparse -cf"
+ verbose=" -v"
+ unpack_preserve=" -xpf"
+ pack_preserve=" -cpf"
+
+ ZVOL_DEVDIR="/dev/zvol"
+ ZVOL_RDEVDIR="/dev/zvol"
+ DEV_RDSKDIR="/dev"
+ DEV_MPATHDIR="/dev/mapper"
+
+ ZEDLET_DIR="/var/tmp/zed"
+ VDEVID_CONF="$ZEDLET_DIR/vdev_id.conf"
+ VDEVID_CONF_ETC="/etc/zfs/vdev_id.conf"
+
+
+ NEWFS_DEFAULT_FS="ext2"
+else
+ unpack_opts="xv"
+ pack_opts="cf"
+ verbose="v"
+ unpack_preserve="xpf"
+ pack_preserve="cpf"
+
+ ZVOL_DEVDIR="/dev/zvol/dsk"
+ ZVOL_RDEVDIR="/dev/zvol/rdsk"
+ DEV_DSKDIR="/dev/dsk"
+ DEV_RDSKDIR="/dev/rdsk"
+
+ NEWFS_DEFAULT_FS="ufs"
+fi
+export unpack_opts pack_opts verbose unpack_preserve pack_preserve \
+ ZVOL_DEVDIR ZVOL_RDEVDIR NEWFS_DEFAULT_FS DEV_RDSKDIR DEV_MPATHDIR \
+ ZEDLET_DIR VDEVID_CONF VDEVID_CONF_ETC
# Setup minimal ZED configuration. Individual test cases should
# add additional ZEDLETs as needed for their specific test.
- log_must cp ${ZEDLETDIR}/zed.rc $ZEDLET_DIR
- log_must cp ${ZEDLETDIR}/zed-functions.sh $ZEDLET_DIR
- log_must cp ${ZEDLETDIR}/all-syslog.sh $ZEDLET_DIR
+ log_must cp ${ZEDLET_ETC_DIR}/zed.rc $ZEDLET_DIR
+ log_must cp ${ZEDLET_ETC_DIR}/zed-functions.sh $ZEDLET_DIR
- log_must zpool events -c
+ # Customize the zed.rc file to enable the full debug log.
+ log_must sed -i '/\#ZED_DEBUG_LOG=.*/d' $ZEDLET_DIR/zed.rc
+ echo "ZED_DEBUG_LOG=$ZEDLET_DIR/zed.debug.log" >>$ZEDLET_DIR/zed.rc
+
+ log_must cp ${ZEDLET_LIBEXEC_DIR}/all-syslog.sh $ZEDLET_DIR
+ log_must cp ${ZEDLET_LIBEXEC_DIR}/all-debug.sh $ZEDLET_DIR
+ log_must touch $ZEDLET_DIR/zed.debug.log
}
#
log_must rm -f ${ZEDLET_DIR}/zed.rc
log_must rm -f ${ZEDLET_DIR}/zed-functions.sh
log_must rm -f ${ZEDLET_DIR}/all-syslog.sh
+ log_must rm -f ${ZEDLET_DIR}/all-debug.sh
log_must rm -f ${ZEDLET_DIR}/zed.pid
log_must rm -f ${ZEDLET_DIR}/zedlog
+ log_must rm -f ${ZEDLET_DIR}/zed.debug.log
log_must rm -f ${ZEDLET_DIR}/state
log_must rm -f $VDEVID_CONF_ETC
log_must rm -f $VDEVID_CONF
# output to zedlog
log_must eval "zed -vF -d $ZEDLET_DIR -p $ZEDLET_DIR/zed.pid" \
"-s $ZEDLET_DIR/state 2>${ZEDLET_DIR}/zedlog &"
+
+ return 0
}
#
return
fi
+ log_note "Stopping ZED"
if [[ -f ${ZEDLET_DIR}/zed.pid ]]; then
zedpid=$(cat ${ZEDLET_DIR}/zed.pid)
log_must kill $zedpid
fi
+
+ return 0
}
#
ctime \
delegate \
devices \
+ events \
exec \
fault \
features \
testpool="${TESTPOOL%%/*}"
fi
-files="$(ls $ZPOOLSCRIPTDIR)"
+files="$(ls $ZPOOL_SCRIPT_DIR)"
scripts=""
for i in $files ; do
- if [ ! -x "$ZPOOLSCRIPTDIR/$i" ] ; then
+ if [ ! -x "$ZPOOL_SCRIPT_DIR/$i" ] ; then
# Skip non-executables
continue
fi
testpool=${TESTPOOL%%/*}
fi
-files="$(ls $ZPOOLSCRIPTDIR)"
+files="$(ls $ZPOOL_SCRIPT_DIR)"
scripts=""
for i in $files ; do
- if [ ! -x "$ZPOOLSCRIPTDIR/$i" ] ; then
+ if [ ! -x "$ZPOOL_SCRIPT_DIR/$i" ] ; then
# Skip non-executables
continue
fi
--- /dev/null
+pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/events
+dist_pkgdata_SCRIPTS = \
+ setup.ksh \
+ cleanup.ksh \
+ events.cfg \
+ events_common.kshlib \
+ events_001_pos.ksh \
+ events_002_pos.ksh
--- /dev/null
+#!/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 (c) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+zed_cleanup
+
+default_cleanup
--- /dev/null
+#
+# 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 (c) 2017 by Lawrence Livermore National Security, LLC.
+# Use is subject to license terms.
+#
+
+export MPOOL=mpool.$$
+
+VDEV1=$TEST_BASE_DIR/vdev1
+VDEV2=$TEST_BASE_DIR/vdev2
+VDEV3=$TEST_BASE_DIR/vdev3
+VDEV4=$TEST_BASE_DIR/vdev4
+
+export TMP_EVENTS=/tmp/tmp_events.$$
+export TMP_EVENTS_FULL=/tmp/tmp_events_full.$$
+export TMP_EVENT_FULL=/tmp/tmp_event_full.$$
+export TMP_EVENTS_ZED=/tmp/tmp_events_zed.$$
+export TMP_EVENT_ZED=/tmp/tmp_event_zed.$$
--- /dev/null
+#!/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 (c) 2017 by Lawrence Livermore National Security, LLC.
+# Use is subject to license terms.
+#
+
+# DESCRIPTION:
+# Verify zpool events command logs events.
+#
+# STRATEGY:
+# 1. Execute zpool sub-commands on a pool.
+# 2. Verify the expected events are logged in 'zpool events'.
+# 3. Verify the expected events are logged by the ZED.
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/events/events_common.kshlib
+
+verify_runnable "both"
+
+function cleanup
+{
+ if poolexists $MPOOL; then
+ destroy_pool $MPOOL
+ fi
+
+ for file in $VDEV1 $VDEV2 $VDEV3 $VDEV4; do
+ [[ -f $file ]] && rm -f $file
+ done
+
+ log_must zed_stop
+}
+
+log_assert "Verify zpool sub-commands generate expected events"
+log_onexit cleanup
+
+log_must truncate -s $MINVDEVSIZE $VDEV1 $VDEV2 $VDEV3 $VDEV4
+log_must zed_start
+
+# Create a mirrored pool with two devices.
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.config_sync" \
+ -e "sysevent.fs.zfs.pool_create" \
+ "zpool create $MPOOL mirror $VDEV1 $VDEV2"
+
+# Add a cache device then remove it.
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.config_sync" \
+ -e "sysevent.fs.zfs.vdev_add" \
+ "zpool add -f $MPOOL spare $VDEV3"
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.vdev_remove_aux" \
+ "zpool remove $MPOOL $VDEV3"
+
+# Add a log device then remove it.
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.config_sync" \
+ -e "sysevent.fs.zfs.vdev_add" \
+ "zpool add -f $MPOOL log $VDEV3"
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.vdev_remove_dev" \
+ "zpool remove $MPOOL $VDEV3"
+
+# Offline then online a device.
+run_and_verify -p "$MPOOL"\
+ -e "resource.fs.zfs.statechange" \
+ -e "sysevent.fs.zfs.config_sync" \
+ "zpool offline $MPOOL $VDEV1"
+run_and_verify -p "$MPOOL" \
+ -e "resource.fs.zfs.statechange" \
+ -e "sysevent.fs.zfs.vdev_online" \
+ -e "sysevent.fs.zfs.config_sync" \
+ "zpool online $MPOOL $VDEV1"
+
+# Attach then detach a device from the mirror.
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.vdev_attach" \
+ "zpool attach $MPOOL $VDEV1 $VDEV4"
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.vdev_remove" \
+ -e "sysevent.fs.zfs.config_sync" \
+ "zpool detach $MPOOL $VDEV4"
+
+# Replace a device
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.vdev_attach" \
+ -e "sysevent.fs.zfs.resilver_start" \
+ -e "sysevent.fs.zfs.resilver_finish" \
+ -e "sysevent.fs.zfs.config_sync" \
+ "zpool replace -f $MPOOL $VDEV1 $VDEV4"
+
+# Scrub a pool.
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.scrub_start" \
+ -e "sysevent.fs.zfs.scrub_finish" \
+ "zpool scrub $MPOOL"
+
+# Export then import a pool (may change to a pool_export event)
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.pool_destroy" \
+ -e "sysevent.fs.zfs.config_sync" \
+ "zpool export $MPOOL"
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.pool_import" \
+ -e "sysevent.fs.zfs.config_sync" \
+ "zpool import -d $TEST_BASE_DIR $MPOOL"
+
+# Destroy the pool
+run_and_verify -p "$MPOOL" \
+ -e "sysevent.fs.zfs.pool_destroy" \
+ -e "sysevent.fs.zfs.config_sync" \
+ "zpool destroy $MPOOL"
+
+log_pass "Verify zpool sub-commands generate expected events"
--- /dev/null
+#!/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 (c) 2017 by Lawrence Livermore National Security, LLC.
+# Use is subject to license terms.
+#
+
+# DESCRIPTION:
+# Verify ZED handles missed events from a pool when starting.
+#
+# STRATEGY:
+# 1. Create a pool and generate some events.
+# 2. Start the ZED and verify it handles missed events.
+# 3. Stop the ZED
+# 4. Generate additional events.
+# 5. Start the ZED and verify it only handles the new missed events.
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/events/events_common.kshlib
+
+verify_runnable "both"
+
+function cleanup
+{
+ if poolexists $MPOOL; then
+ destroy_pool $MPOOL
+ fi
+
+ for file in $VDEV1 $VDEV2; do
+ [[ -f $file ]] && rm -f $file
+ done
+
+ log_must rm -f $TMP_EVENTS_ZED $TMP_EVENTS_ZED
+ log_must rm -f $ZEDLET_DIR/zed.debug.log.old
+ log_must zed_stop
+}
+
+log_assert "Verify ZED handles missed events on when starting"
+log_onexit cleanup
+
+log_must truncate -s $MINVDEVSIZE $VDEV1 $VDEV2
+
+# 1. Create a pool and generate some events.
+log_must cp -f $ZEDLET_DIR/zed.debug.log $ZEDLET_DIR/zed.debug.log.old
+log_must zpool create $MPOOL mirror $VDEV1 $VDEV2
+
+# 2. Start the ZED and verify it handles missed events.
+log_must zed_start
+log_must sleep 1
+diff $ZEDLET_DIR/zed.debug.log.old $ZEDLET_DIR/zed.debug.log | \
+ grep "^> " | sed 's/^> //g' >$TMP_EVENTS_ZED
+log_must awk -v event="sysevent.fs.zfs.pool_create" \
+ 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \
+ $TMP_EVENTS_ZED >$TMP_EVENT_ZED
+log_must grep -q "^ZEVENT_POOL=$MPOOL" $TMP_EVENT_ZED
+
+# 3. Stop the ZED
+zed_stop
+
+# 4. Generate additional events.
+log_must cp -f $ZEDLET_DIR/zed.debug.log $ZEDLET_DIR/zed.debug.log.old
+log_must zpool offline $MPOOL $VDEV1
+log_must zpool online $MPOOL $VDEV1
+log_must zpool scrub $MPOOL
+
+# Wait for the scrub to wrap, or is_healthy will be wrong.
+while ! is_pool_scrubbed $MPOOL; do
+ sleep 1
+done
+
+# 5. Start the ZED and verify it only handled the new missed events.
+log_must zed_start
+log_must sleep 3
+diff $ZEDLET_DIR/zed.debug.log.old $ZEDLET_DIR/zed.debug.log | \
+ grep "^> " | sed 's/^> //g' >$TMP_EVENTS_ZED
+
+log_mustnot grep -q "sysevent.fs.zfs.pool_create" $TMP_EVENTS_ZED
+log_must grep -q "sysevent.fs.zfs.vdev_online" $TMP_EVENTS_ZED
+log_must grep -q "sysevent.fs.zfs.resilver_start" $TMP_EVENTS_ZED
+log_must grep -q "sysevent.fs.zfs.resilver_finish" $TMP_EVENTS_ZED
+
+log_pass "Verify ZED handles missed events on when starting"
--- /dev/null
+#
+# 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 (c) 2017 by Lawrence Livermore National Security, LLC.
+# Use is subject to license terms.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/events/events.cfg
+
+function run_and_verify
+{
+ typeset event pool
+ set -A events
+
+ while getopts "e:p:z:" opt; do
+ case $opt in
+ e)
+ events[${#events[*]}+1]=$OPTARG
+ ;;
+ p)
+ pool=$OPTARG
+ ;;
+ z)
+ zedlog=$OPTARG
+ ;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+
+ pool=${pool:-$TESTPOOL}
+ zedlog=${zedlog:-$ZEDLET_DIR/zed.debug.log}
+ fullcmd="$1"
+ cmd=$(echo $fullcmd | awk '{print $1}')
+ subcmd=$(echo $fullcmd | awk '{print $2}')
+
+ # If we aren't running zpool or zfs, something is wrong
+ [[ $cmd == "zpool" || $cmd == "zfs" ]] || \
+ log_fail "run_and_verify called with \"$cmd ($fullcmd)\""
+
+ # Run the command as provided and collect the new events.
+ log_must zpool events -c
+ if [[ -f $zedlog ]]; then
+ cp -f $zedlog $zedlog.old
+ fi
+
+ log_must eval "$fullcmd"
+
+ log_must zpool events > $TMP_EVENTS 2>/dev/null
+ log_must zpool events -v > $TMP_EVENTS_FULL 2>/dev/null
+ if [[ -f $zedlog ]]; then
+ sleep 1 # Brief delay for the ZED to handle the event.
+ diff $zedlog.old $zedlog | grep "^> " | sed 's/^> //g' \
+ >$TMP_EVENTS_ZED
+ fi
+
+ # Verify all the expected events appear in the log.
+ for event in ${events[*]}; do
+
+ # Verify the event is in in the short output.
+ log_must grep -q "$event" $TMP_EVENTS
+
+ # Verify the event is in the verbose output with pool name.
+ log_must awk -v event="$event" \
+ 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \
+ $TMP_EVENTS_FULL >$TMP_EVENT_FULL
+ log_must grep -q "pool = \"$pool\"" $TMP_EVENT_FULL
+
+ # Verify the event was received by the ZED and logged.
+ log_must awk -v event="$event" \
+ 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \
+ $TMP_EVENTS_ZED >$TMP_EVENT_ZED
+ log_must grep -q "^ZEVENT_POOL=$pool" $TMP_EVENT_ZED
+
+ done
+
+ log_must rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENT_FULL \
+ $TMP_EVENTS_ZED $TMP_EVENT_ZED $zedlog.old
+}
--- /dev/null
+#!/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 (c) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+DISK=${DISKS%% *}
+
+zed_setup
+
+default_setup $DISK
export TESTSDIR=${SRCDIR}/tests
export RUNFILEDIR=${TESTSDIR}/runfiles
export UDEVRULEDIR=${BUILDDIR}/udev/rules.d
-export ZEDLETDIR=${SRCDIR}/cmd/zed/zed.d
-export ZPOOLSCRIPTDIR=${SRCDIR}/cmd/zpool/zpool.d
+
+export ZEDLET_ETC_DIR=${SRCDIR}/cmd/zed/zed.d
+export ZEDLET_LIBEXEC_DIR=${SRCDIR}/cmd/zed/zed.d
+export ZPOOL_SCRIPT_DIR=${SRCDIR}/cmd/zpool/zpool.d
export ZDB=${CMDDIR}/zdb/zdb
export ZFS=${CMDDIR}/zfs/zfs