Allow 'zpool events' filtering by pool name
Additionally add four new tests: * zpool_events_clear: verify 'zpool events -c' functionality * zpool_events_cliargs: verify command line options and arguments * zpool_events_follow: verify 'zpool events -f' * zpool_events_poolname: verify events filtering by pool name Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #3285 Closes #6762
This commit is contained in:
parent
a032ac4b38
commit
88f9c9396b
|
@ -354,7 +354,7 @@ get_usage(zpool_help_t idx)
|
||||||
"\tupgrade -v\n"
|
"\tupgrade -v\n"
|
||||||
"\tupgrade [-V version] <-a | pool ...>\n"));
|
"\tupgrade [-V version] <-a | pool ...>\n"));
|
||||||
case HELP_EVENTS:
|
case HELP_EVENTS:
|
||||||
return (gettext("\tevents [-vHfc]\n"));
|
return (gettext("\tevents [-vHf [pool] | -c]\n"));
|
||||||
case HELP_GET:
|
case HELP_GET:
|
||||||
return (gettext("\tget [-Hp] [-o \"all\" | field[,...]] "
|
return (gettext("\tget [-Hp] [-o \"all\" | field[,...]] "
|
||||||
"<\"all\" | property[,...]> <pool> ...\n"));
|
"<\"all\" | property[,...]> <pool> ...\n"));
|
||||||
|
@ -7376,6 +7376,7 @@ typedef struct ev_opts {
|
||||||
int scripted;
|
int scripted;
|
||||||
int follow;
|
int follow;
|
||||||
int clear;
|
int clear;
|
||||||
|
char poolname[ZFS_MAX_DATASET_NAME_LEN];
|
||||||
} ev_opts_t;
|
} ev_opts_t;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -7643,6 +7644,7 @@ zpool_do_events_next(ev_opts_t *opts)
|
||||||
{
|
{
|
||||||
nvlist_t *nvl;
|
nvlist_t *nvl;
|
||||||
int zevent_fd, ret, dropped;
|
int zevent_fd, ret, dropped;
|
||||||
|
char *pool;
|
||||||
|
|
||||||
zevent_fd = open(ZFS_DEV, O_RDWR);
|
zevent_fd = open(ZFS_DEV, O_RDWR);
|
||||||
VERIFY(zevent_fd >= 0);
|
VERIFY(zevent_fd >= 0);
|
||||||
|
@ -7659,6 +7661,11 @@ zpool_do_events_next(ev_opts_t *opts)
|
||||||
if (dropped > 0)
|
if (dropped > 0)
|
||||||
(void) printf(gettext("dropped %d events\n"), dropped);
|
(void) printf(gettext("dropped %d events\n"), dropped);
|
||||||
|
|
||||||
|
if (strlen(opts->poolname) > 0 &&
|
||||||
|
nvlist_lookup_string(nvl, FM_FMRI_ZFS_POOL, &pool) == 0 &&
|
||||||
|
strcmp(opts->poolname, pool) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
zpool_do_events_short(nvl, opts);
|
zpool_do_events_short(nvl, opts);
|
||||||
|
|
||||||
if (opts->verbose) {
|
if (opts->verbose) {
|
||||||
|
@ -7688,7 +7695,7 @@ zpool_do_events_clear(ev_opts_t *opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* zpool events [-vfc]
|
* zpool events [-vHf [pool] | -c]
|
||||||
*
|
*
|
||||||
* Displays events logs by ZFS.
|
* Displays events logs by ZFS.
|
||||||
*/
|
*/
|
||||||
|
@ -7723,6 +7730,25 @@ zpool_do_events(int argc, char **argv)
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
(void) fprintf(stderr, gettext("too many arguments\n"));
|
||||||
|
usage(B_FALSE);
|
||||||
|
} else if (argc == 1) {
|
||||||
|
(void) strlcpy(opts.poolname, argv[0], sizeof (opts.poolname));
|
||||||
|
if (!zfs_name_valid(opts.poolname, ZFS_TYPE_POOL)) {
|
||||||
|
(void) fprintf(stderr,
|
||||||
|
gettext("invalid pool name '%s'\n"), opts.poolname);
|
||||||
|
usage(B_FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((argc == 1 || opts.verbose || opts.scripted || opts.follow) &&
|
||||||
|
opts.clear) {
|
||||||
|
(void) fprintf(stderr,
|
||||||
|
gettext("invalid options combined with -c\n"));
|
||||||
|
usage(B_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.clear)
|
if (opts.clear)
|
||||||
ret = zpool_do_events_clear(&opts);
|
ret = zpool_do_events_clear(&opts);
|
||||||
else
|
else
|
||||||
|
|
|
@ -214,6 +214,7 @@ AC_CONFIG_FILES([
|
||||||
tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile
|
tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile
|
||||||
tests/zfs-tests/tests/functional/cli_root/zpool_destroy/Makefile
|
tests/zfs-tests/tests/functional/cli_root/zpool_destroy/Makefile
|
||||||
tests/zfs-tests/tests/functional/cli_root/zpool_detach/Makefile
|
tests/zfs-tests/tests/functional/cli_root/zpool_detach/Makefile
|
||||||
|
tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile
|
||||||
tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile
|
tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile
|
||||||
tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile
|
tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile
|
||||||
tests/zfs-tests/tests/functional/cli_root/zpool_get/Makefile
|
tests/zfs-tests/tests/functional/cli_root/zpool_get/Makefile
|
||||||
|
|
|
@ -68,8 +68,7 @@
|
||||||
.Ar pool device
|
.Ar pool device
|
||||||
.Nm
|
.Nm
|
||||||
.Cm events
|
.Cm events
|
||||||
.Op Fl vHfc
|
.Op Fl vHf Oo Ar pool Oc | Fl c
|
||||||
.Op Ar pool
|
|
||||||
.Nm
|
.Nm
|
||||||
.Cm export
|
.Cm export
|
||||||
.Op Fl a
|
.Op Fl a
|
||||||
|
@ -1027,8 +1026,7 @@ command instead.
|
||||||
.It Xo
|
.It Xo
|
||||||
.Nm
|
.Nm
|
||||||
.Cm events
|
.Cm events
|
||||||
.Op Fl cfHv
|
.Op Fl vHf Oo Ar pool Oc | Fl c
|
||||||
.Op Ar pool Ns ...
|
|
||||||
.Xc
|
.Xc
|
||||||
Lists all recent events generated by the ZFS kernel modules. These events
|
Lists all recent events generated by the ZFS kernel modules. These events
|
||||||
are consumed by the
|
are consumed by the
|
||||||
|
|
|
@ -252,6 +252,10 @@ post =
|
||||||
[tests/functional/cli_root/zpool_detach]
|
[tests/functional/cli_root/zpool_detach]
|
||||||
tests = ['zpool_detach_001_neg']
|
tests = ['zpool_detach_001_neg']
|
||||||
|
|
||||||
|
[tests/functional/cli_root/zpool_events]
|
||||||
|
tests = ['zpool_events_clear', 'zpool_events_cliargs', 'zpool_events_follow',
|
||||||
|
'zpool_events_poolname']
|
||||||
|
|
||||||
[tests/functional/cli_root/zpool_expand]
|
[tests/functional/cli_root/zpool_expand]
|
||||||
tests = ['zpool_expand_001_pos', 'zpool_expand_002_pos',
|
tests = ['zpool_expand_001_pos', 'zpool_expand_002_pos',
|
||||||
'zpool_expand_003_neg', 'zpool_expand_004_pos']
|
'zpool_expand_003_neg', 'zpool_expand_004_pos']
|
||||||
|
|
|
@ -37,6 +37,7 @@ SUBDIRS = \
|
||||||
zpool_create \
|
zpool_create \
|
||||||
zpool_destroy \
|
zpool_destroy \
|
||||||
zpool_detach \
|
zpool_detach \
|
||||||
|
zpool_events \
|
||||||
zpool_expand \
|
zpool_expand \
|
||||||
zpool_export \
|
zpool_export \
|
||||||
zpool_get \
|
zpool_get \
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_events
|
||||||
|
dist_pkgdata_SCRIPTS = \
|
||||||
|
setup.ksh \
|
||||||
|
cleanup.ksh \
|
||||||
|
zpool_events.cfg \
|
||||||
|
zpool_events.kshlib \
|
||||||
|
zpool_events_clear.ksh \
|
||||||
|
zpool_events_cliargs.ksh \
|
||||||
|
zpool_events_follow.ksh \
|
||||||
|
zpool_events_poolname.ksh
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
|
||||||
|
default_cleanup
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
|
||||||
|
DISK=${DISKS%% *}
|
||||||
|
|
||||||
|
default_volume_setup $DISK
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
export EVENTS_NUM=42
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
. $STF_SUITE/tests/functional/cli_root/zpool_events/zpool_events.cfg
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wait to allow the kernel module to process ZFS events until we reach $eventnum
|
||||||
|
# or a timeout of $timeout seconds expire, whichever comes first
|
||||||
|
#
|
||||||
|
function zpool_events_settle # <eventnum> [timeout]
|
||||||
|
{
|
||||||
|
typeset eventnum="${1:-$EVENTS_NUM}"
|
||||||
|
typeset timeout="${2:-3}"
|
||||||
|
typeset -i count
|
||||||
|
typeset -i i=0
|
||||||
|
|
||||||
|
while [[ $i -lt $timeout ]]; do
|
||||||
|
count=$(zpool events -H | wc -l)
|
||||||
|
if [[ $count -ge $eventnum ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
log_note "waited $i seconds"
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
. $STF_SUITE/tests/functional/cli_root/zpool_events/zpool_events.kshlib
|
||||||
|
|
||||||
|
#
|
||||||
|
# DESCRIPTION:
|
||||||
|
# 'zpool events -c' should successfully clear events.
|
||||||
|
#
|
||||||
|
# STRATEGY:
|
||||||
|
# 1. Clear all ZFS events
|
||||||
|
# 2. Generate some new ZFS events
|
||||||
|
# 3. Verify 'zpool events -c' successfully clears new events
|
||||||
|
#
|
||||||
|
|
||||||
|
verify_runnable "both"
|
||||||
|
|
||||||
|
log_assert "'zpool events -c' should successfully clear events."
|
||||||
|
|
||||||
|
# 1. Clear all ZFS events
|
||||||
|
# This is needed because we may already over the max number or events queued
|
||||||
|
# (zfs_zevent_len_max) generated by previous tests: generating $EVENTS_NUM new
|
||||||
|
# events and then counting them is racy and leads to failues, so start from 0.
|
||||||
|
log_must zpool events -c
|
||||||
|
|
||||||
|
# 2. Generate some new ZFS events
|
||||||
|
for i in `seq 1 $EVENTS_NUM`; do
|
||||||
|
log_must zpool clear $TESTPOOL
|
||||||
|
done
|
||||||
|
# wait a bit to allow the kernel module to process new events
|
||||||
|
zpool_events_settle
|
||||||
|
EVENTS_NUM="$(zpool events -H | wc -l)"
|
||||||
|
|
||||||
|
# 3. Verify 'zpool events -c' successfully clear new events
|
||||||
|
CLEAR_OUTPUT="$(zpool events -c)"
|
||||||
|
if [[ "$CLEAR_OUTPUT" != "cleared $EVENTS_NUM events" ]]; then
|
||||||
|
log_fail "Failed to clear $EVENTS_NUM events: $CLEAR_OUTPUT"
|
||||||
|
fi
|
||||||
|
EVENTS_NUM="$(zpool events -H | wc -l)"
|
||||||
|
if [[ $EVENTS_NUM -ne 0 ]]; then
|
||||||
|
log_fail "Unexpected events number: $EVENTS_NUM != 0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_pass "'zpool events -c' successfully clears events."
|
|
@ -0,0 +1,89 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
|
||||||
|
#
|
||||||
|
# DESCRIPTION:
|
||||||
|
# 'zpool events' should only work with supported options.
|
||||||
|
#
|
||||||
|
# STRATEGY:
|
||||||
|
# 1. Verify every supported option is accepted
|
||||||
|
# 2. Verify supported options raise an error with unsupported arguments
|
||||||
|
# 3. Verify other unsupported options raise an error
|
||||||
|
#
|
||||||
|
|
||||||
|
verify_runnable "both"
|
||||||
|
|
||||||
|
function log_must_follow # <command>
|
||||||
|
{
|
||||||
|
typeset command="$1"
|
||||||
|
|
||||||
|
log_must eval "$command > /dev/null &"
|
||||||
|
pid=$!
|
||||||
|
sleep 3
|
||||||
|
kill $pid
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
log_fail "'$command' does not work as expected."
|
||||||
|
else
|
||||||
|
log_note "'$command' works successfully."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
log_assert "'zpool events' should only work with supported options."
|
||||||
|
|
||||||
|
typeset goodopts=("" "-v" "-H" "-f" "-vH" "-vf" "-Hf" "-vHf")
|
||||||
|
typeset badopts=("-vV" "-Hh" "-fF" "-cC" "-x" "-o" "-")
|
||||||
|
|
||||||
|
# 1. Verify every supported option is accepted
|
||||||
|
for opt in ${goodopts[@]}
|
||||||
|
do
|
||||||
|
# when in 'follow' mode we can't use log_must()
|
||||||
|
if [[ $opt =~ 'f' ]]; then
|
||||||
|
log_must_follow "zpool events $opt"
|
||||||
|
log_must_follow "zpool events $opt $TESTPOOL"
|
||||||
|
else
|
||||||
|
log_must eval "zpool events $opt > /dev/null"
|
||||||
|
log_must eval "zpool events $opt $TESTPOOL > /dev/null"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 2.1 Verify supported options raise an error with unsupported arguments
|
||||||
|
for opt in ${goodopts[@]}
|
||||||
|
do
|
||||||
|
log_mustnot zpool events $opt "/tmp/"
|
||||||
|
log_mustnot zpool events $opt "$TESTPOOL/fs"
|
||||||
|
log_mustnot zpool events $opt "$TESTPOOL@snap"
|
||||||
|
log_mustnot zpool events $opt "$TESTPOOL#bm"
|
||||||
|
log_mustnot zpool events $opt "$TESTPOOL" "$TESTPOOL"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 2.2 Additionally, 'zpool events -c' does not support any other option|argument
|
||||||
|
log_must eval "zpool events -c > /dev/null"
|
||||||
|
log_mustnot zpool events -c "$TESTPOOL"
|
||||||
|
for opt in ${goodopts[@]}
|
||||||
|
do
|
||||||
|
log_mustnot zpool events -c $opt
|
||||||
|
done
|
||||||
|
|
||||||
|
# 3. Verify other unsupported options raise an error
|
||||||
|
for opt in ${badopts[@]}
|
||||||
|
do
|
||||||
|
log_mustnot zpool events $opt
|
||||||
|
log_mustnot zpool events $opt "$TESTPOOL"
|
||||||
|
done
|
||||||
|
|
||||||
|
log_pass "'zpool events' only works with supported options."
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
. $STF_SUITE/tests/functional/cli_root/zpool_events/zpool_events.kshlib
|
||||||
|
|
||||||
|
#
|
||||||
|
# DESCRIPTION:
|
||||||
|
# 'zpool events -f' should successfully follow new events.
|
||||||
|
#
|
||||||
|
# STRATEGY:
|
||||||
|
# 1. Clear all ZFS events
|
||||||
|
# 2. Run 'zpool events -f' in background, saving its output to a temporary file
|
||||||
|
# 3. Generate some ZFS events
|
||||||
|
# 4. Verify 'zpool events -f' successfully recorded these new events
|
||||||
|
#
|
||||||
|
|
||||||
|
verify_runnable "both"
|
||||||
|
|
||||||
|
function cleanup
|
||||||
|
{
|
||||||
|
[[ -n $pid ]] && kill $pid 2>/dev/null
|
||||||
|
rm -f $EVENTS_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
log_assert "'zpool events -f' should follow new events."
|
||||||
|
log_onexit cleanup
|
||||||
|
|
||||||
|
EVENTS_FILE="$TESTDIR/zpool_events.$$"
|
||||||
|
|
||||||
|
# 1. Clear all ZFS events
|
||||||
|
log_must zpool events -c
|
||||||
|
|
||||||
|
# 2. Run 'zpool events -f' in background, saving its output to a temporary file
|
||||||
|
log_must eval "zpool events -H -f > $EVENTS_FILE &"
|
||||||
|
pid=$!
|
||||||
|
|
||||||
|
# 3. Generate some ZFS events
|
||||||
|
for i in `seq 1 $EVENTS_NUM`; do
|
||||||
|
log_must zpool clear $TESTPOOL
|
||||||
|
done
|
||||||
|
# wait a bit to allow the kernel module to process new events
|
||||||
|
zpool_events_settle
|
||||||
|
|
||||||
|
# 4. Verify 'zpool events -f' successfully recorded these new events
|
||||||
|
EVENTS_LOG="$(cat $EVENTS_FILE | wc -l)"
|
||||||
|
if [[ "$EVENTS_LOG" != "$EVENTS_NUM" ]]; then
|
||||||
|
log_fail "Unexpected number of events: $EVENTS_LOG != $EVENTS_NUM"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_pass "'zpool events -f' successfully follows new events."
|
|
@ -0,0 +1,74 @@
|
||||||
|
#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
|
||||||
|
#
|
||||||
|
|
||||||
|
. $STF_SUITE/include/libtest.shlib
|
||||||
|
. $STF_SUITE/tests/functional/cli_root/zpool_events/zpool_events.kshlib
|
||||||
|
|
||||||
|
#
|
||||||
|
# DESCRIPTION:
|
||||||
|
# 'zpool events poolname' should only display events from the chosen pool.
|
||||||
|
#
|
||||||
|
# STRATEGY:
|
||||||
|
# 1. Create an additional pool
|
||||||
|
# 2. Clear all ZFS events
|
||||||
|
# 3. Generate some ZFS events on both pools
|
||||||
|
# 4. Verify 'zpool events poolname' successfully display events
|
||||||
|
#
|
||||||
|
|
||||||
|
verify_runnable "both"
|
||||||
|
|
||||||
|
function cleanup
|
||||||
|
{
|
||||||
|
destroy_pool $NEWPOOL
|
||||||
|
rm -f $DISK
|
||||||
|
}
|
||||||
|
|
||||||
|
log_assert "'zpool events poolname' should only display events from poolname."
|
||||||
|
log_onexit cleanup
|
||||||
|
|
||||||
|
NEWPOOL="newpool"
|
||||||
|
DISK="$TEST_BASE_DIR/$NEWPOOL.dat"
|
||||||
|
|
||||||
|
# 1. Create an additional pool
|
||||||
|
log_must truncate -s $MINVDEVSIZE $DISK
|
||||||
|
log_must zpool create $NEWPOOL $DISK
|
||||||
|
|
||||||
|
# 2. Clear all ZFS events
|
||||||
|
log_must zpool events -c
|
||||||
|
|
||||||
|
# 3. Generate some ZFS events on both pools
|
||||||
|
for i in `seq 1 $EVENTS_NUM`; do
|
||||||
|
log_must zpool clear $TESTPOOL
|
||||||
|
done
|
||||||
|
for i in `seq 1 $EVENTS_NUM`; do
|
||||||
|
log_must zpool clear $NEWPOOL
|
||||||
|
done
|
||||||
|
# wait a bit to allow the kernel module to process new events
|
||||||
|
zpool_events_settle
|
||||||
|
|
||||||
|
# 4. Verify 'zpool events poolname' successfully display events
|
||||||
|
zpool events -v $TESTPOOL |
|
||||||
|
awk -v POOL=$TESTPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}'
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
log_fail "Unexpected events for pools other than $TESTPOOL"
|
||||||
|
fi
|
||||||
|
zpool events -v $NEWPOOL |
|
||||||
|
awk -v POOL=$NEWPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}'
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
log_fail "Unexpected events for pools other than $NEWPOOL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_pass "'zpool events poolname' display events only from the chosen pool."
|
|
@ -111,7 +111,7 @@ do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clear zpool events
|
# Clear zpool events
|
||||||
zpool events -c $TESTPOOL
|
log_must zpool events -c
|
||||||
|
|
||||||
# Online disk
|
# Online disk
|
||||||
insert_disk $offline_disk $host
|
insert_disk $offline_disk $host
|
||||||
|
|
|
@ -122,7 +122,7 @@ if (($? != 0)); then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clear zpool events
|
# Clear zpool events
|
||||||
zpool events -c $TESTPOOL
|
log_must zpool events -c
|
||||||
|
|
||||||
# Create another scsi_debug device
|
# Create another scsi_debug device
|
||||||
setup
|
setup
|
||||||
|
|
Loading…
Reference in New Issue