]> git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/events/zed_rc_filter.ksh
New upstream version 0.7.9
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / events / zed_rc_filter.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
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.
8 #
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.
13 #
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]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
25 # Use is subject to license terms.
26 #
27
28 # DESCRIPTION:
29 # Verify zed.rc ZED_SYSLOG_SUBCLASS_INCLUDE/EXCLUDE event filtering works.
30 #
31 # STRATEGY:
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.
36
37 . $STF_SUITE/include/libtest.shlib
38 . $STF_SUITE/tests/functional/events/events_common.kshlib
39
40 verify_runnable "both"
41
42 function cleanup
43 {
44 log_must zed_stop
45 zed_rc_restore $zedrc_backup
46 }
47
48 log_assert "Verify zpool sub-commands generate expected events"
49 log_onexit cleanup
50
51 log_must zpool events -c
52 log_must zed_start
53
54 # Backup our zed.rc
55 zedrc_backup=$(zed_rc_backup)
56
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"
61
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"
66
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"
71
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"
77
78 # We can't use run_and_verify() for exclusions, so run the rest of the tests
79 # manually.
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
86
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
93
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
98 zpool scrub $TESTPOOL
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
103
104 log_pass "zed.rc event filtering works correctly."