5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
25 # Use is subject to license terms.
29 # Verify zed.rc ZED_SYSLOG_SUBCLASS_INCLUDE/EXCLUDE event filtering works.
32 # 1. Execute zpool sub-commands on a pool.
33 # 2. Test different combinations of ZED_SYSLOG_SUBCLASS_INCLUDE filtering.
34 # 3. Execute zpool sub-commands on a pool.
35 # 4. Test different combinations of ZED_SYSLOG_SUBCLASS_EXCLUDE filtering.
37 .
$STF_SUITE/include
/libtest.shlib
38 .
$STF_SUITE/tests
/functional
/events
/events_common.kshlib
40 verify_runnable
"both"
45 zed_rc_restore
$zedrc_backup
48 log_assert
"Verify zpool sub-commands generate expected events"
51 log_must zpool events
-c
55 zedrc_backup
=$
(zed_rc_backup
)
57 log_note
"Include a single event type"
58 zed_rc_set ZED_SYSLOG_SUBCLASS_INCLUDE history_event
59 run_and_verify
-p "$TESTPOOL" -e "sysevent.fs.zfs.history_event" \
60 "zfs set compression=off $TESTPOOL/$TESTFS"
62 log_note
"Include a single event type with wildcards"
63 zed_rc_set ZED_SYSLOG_SUBCLASS_INCLUDE
'*history_event*'
64 run_and_verify
-p "$TESTPOOL" -e "sysevent.fs.zfs.history_event" \
65 "zfs set compression=off $TESTPOOL/$TESTFS"
67 log_note
"Test a filter of a non-match and a match"
68 zed_rc_set ZED_SYSLOG_SUBCLASS_INCLUDE
'foobar|*history_event*'
69 run_and_verify
-p "$TESTPOOL" -e "sysevent.fs.zfs.history_event" \
70 "zfs set compression=off $TESTPOOL/$TESTFS"
72 log_note
"Include multiple events"
73 zed_rc_set ZED_SYSLOG_SUBCLASS_INCLUDE
'scrub_start|scrub_finish'
74 run_and_verify
-p "$TESTPOOL" -e "sysevent.fs.zfs.scrub_start" \
75 -e "sysevent.fs.zfs.scrub_finish" \
76 "zpool scrub $TESTPOOL && wait_scrubbed $TESTPOOL"
78 # We can't use run_and_verify() for exclusions, so run the rest of the tests
80 log_note
"Test one exclusion"
81 zed_rc_set ZED_SYSLOG_SUBCLASS_EXCLUDE
'history_event'
82 truncate
-s 0 $ZED_DEBUG_LOG
83 log_must zfs
set compression
=off
$TESTPOOL/$TESTFS
84 log_must file_wait
$ZED_DEBUG_LOG 3
85 log_mustnot
grep -q history_event
$ZED_DEBUG_LOG
87 log_note
"Test one exclusion with wildcards"
88 zed_rc_set ZED_SYSLOG_SUBCLASS_EXCLUDE
'*history_event*'
89 truncate
-s 0 $ZED_DEBUG_LOG
90 log_must zfs
set compression
=off
$TESTPOOL/$TESTFS
91 log_must file_wait
$ZED_DEBUG_LOG 3
92 log_mustnot
grep -q history_event
$ZED_DEBUG_LOG
94 log_note
"Test one inclusion and one exclusion"
95 zed_rc_set ZED_SYSLOG_SUBCLASS_INCLUDE
'scrub_start'
96 zed_rc_set ZED_SYSLOG_SUBCLASS_EXCLUDE
'scrub_finish'
97 truncate
-s 0 $ZED_DEBUG_LOG
99 wait_scrubbed
$TESTPOOL
100 log_must file_wait
$ZED_DEBUG_LOG 3
101 log_must
grep -q scrub_start
$ZED_DEBUG_LOG
102 log_mustnot
grep -q scrub_finish
$ZED_DEBUG_LOG
104 log_pass
"zed.rc event filtering works correctly."