Add scrub after resilver zed script

* Add a zed script to kick off a scrub after a resilver.  The script is
disabled by default.

* Add a optional $PATH (-P) option to zed to allow it to use a custom
$PATH for its zedlets.  This is needed when you're running zed under
the ZTS in a local workspace.

* Update test scripts to not copy in all-debug.sh and all-syslog.sh by
default.  They can be optionally copied in as part of zed_setup().
These scripts slow down zed considerably under heavy events loads and
can cause events to be dropped or their delivery delayed. This was
causing some sporadic failures in the 'fault' tests.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #4662 
Closes #7086
This commit is contained in:
Tony Hutter
2018-02-23 11:38:05 -08:00
committed by Brian Behlendorf
parent e9a7729008
commit bf95a000c4
16 changed files with 187 additions and 21 deletions
@@ -26,6 +26,6 @@
. $STF_SUITE/include/libtest.shlib
zed_cleanup
zed_cleanup all-debug.sh all-syslog.sh
default_cleanup
@@ -28,6 +28,6 @@
DISK=${DISKS%% *}
zed_setup
zed_setup all-debug.sh all-syslog.sh
default_setup $DISK
@@ -8,4 +8,5 @@ dist_pkgdata_SCRIPTS = \
auto_spare_001_pos.ksh \
auto_spare_002_pos.ksh \
auto_spare_ashift.ksh \
auto_spare_multiple.ksh
auto_spare_multiple.ksh \
scrub_after_resilver.ksh
@@ -31,6 +31,6 @@ verify_runnable "global"
cleanup_devices $DISKS
zed_stop
zed_cleanup
zed_cleanup resilver_finish-start-scrub.sh
log_pass
@@ -0,0 +1,65 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
# All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/fault/fault.cfg
#
# DESCRIPTION:
# Test the scrub after resilver zedlet
#
# STRATEGY:
# 1. Create a mirrored pool
# 2. Fault a disk
# 3. Replace the disk, starting a resilver
# 4. Verify that a scrub happens after the resilver finishes
#
log_assert "Testing the scrub after resilver zedlet"
# Backup our zed.rc
zedrc_backup="$(mktemp)"
log_must cp $ZEDLET_DIR/zed.rc $zedrc_backup
# Enable ZED_SCRUB_AFTER_RESILVER
eval "sed -i 's/\#ZED_SCRUB_AFTER_RESILVER/ZED_SCRUB_AFTER_RESILVER/g' $ZEDLET_DIR/zed.rc"
function cleanup
{
# Restore our zed.rc
log_must mv $zedrc_backup $ZEDLET_DIR/zed.rc
default_cleanup_noexit
}
log_onexit cleanup
verify_disk_count "$DISKS" 3
default_mirror_setup_noexit $DISK1 $DISK2
log_must zpool offline -f $TESTPOOL $DISK1
# Write to our degraded pool so we have some data to resilver
log_must mkfile 16M $TESTDIR/file1
# Replace the failed disks, forcing a resilver
log_must zpool replace $TESTPOOL $DISK1 $DISK3
# Wait for the resilver to finish, and then the subsequent scrub to finish.
# Waiting for the scrub has the effect of waiting for both. Timeout after 10
# seconds if nothing is happening.
log_must wait_scrubbed $TESTPOOL 10
log_pass "Successfully ran the scrub after resilver zedlet"
@@ -28,7 +28,7 @@
verify_runnable "global"
zed_setup
zed_setup resilver_finish-start-scrub.sh
zed_start
log_pass