]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/events/events_001_pos.ksh
aaf2ad86c1ec8848affd3c32df0bb30bc3ae4427
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) 2017 by Lawrence Livermore National Security, LLC.
25 # Use is subject to license terms.
29 # Verify zpool events command logs events.
32 # 1. Execute zpool sub-commands on a pool.
33 # 2. Verify the expected events are logged in 'zpool events'.
34 # 3. Verify the expected events are logged by the ZED.
36 .
$STF_SUITE/include
/libtest.shlib
37 .
$STF_SUITE/tests
/functional
/events
/events_common.kshlib
39 verify_runnable
"both"
43 if poolexists
$MPOOL; then
47 for file in $VDEV1 $VDEV2 $VDEV3 $VDEV4; do
48 [[ -f $file ]] && rm -f $file
54 log_assert
"Verify zpool sub-commands generate expected events"
57 log_must truncate
-s $MINVDEVSIZE $VDEV1 $VDEV2 $VDEV3 $VDEV4
60 # Create a mirrored pool with two devices.
61 run_and_verify
-p "$MPOOL" \
62 -e "sysevent.fs.zfs.config_sync" \
63 -e "sysevent.fs.zfs.pool_create" \
64 "zpool create $MPOOL mirror $VDEV1 $VDEV2"
66 # Add a cache device then remove it.
67 run_and_verify
-p "$MPOOL" \
68 -e "sysevent.fs.zfs.config_sync" \
69 -e "sysevent.fs.zfs.vdev_add" \
70 "zpool add -f $MPOOL spare $VDEV3"
71 run_and_verify
-p "$MPOOL" \
72 -e "sysevent.fs.zfs.vdev_remove_aux" \
73 "zpool remove $MPOOL $VDEV3"
75 # Add a log device then remove it.
76 run_and_verify
-p "$MPOOL" \
77 -e "sysevent.fs.zfs.config_sync" \
78 -e "sysevent.fs.zfs.vdev_add" \
79 "zpool add -f $MPOOL log $VDEV3"
80 run_and_verify
-p "$MPOOL" \
81 -e "sysevent.fs.zfs.vdev_remove_dev" \
82 "zpool remove $MPOOL $VDEV3"
84 # Offline then online a device.
85 run_and_verify
-p "$MPOOL"\
86 -e "resource.fs.zfs.statechange" \
87 -e "sysevent.fs.zfs.config_sync" \
88 "zpool offline $MPOOL $VDEV1"
89 run_and_verify
-p "$MPOOL" \
90 -e "resource.fs.zfs.statechange" \
91 -e "sysevent.fs.zfs.vdev_online" \
92 -e "sysevent.fs.zfs.config_sync" \
93 "zpool online $MPOOL $VDEV1"
95 # Attach then detach a device from the mirror.
96 run_and_verify
-p "$MPOOL" \
97 -e "sysevent.fs.zfs.vdev_attach" \
98 "zpool attach $MPOOL $VDEV1 $VDEV4"
99 run_and_verify
-p "$MPOOL" \
100 -e "sysevent.fs.zfs.vdev_remove" \
101 -e "sysevent.fs.zfs.config_sync" \
102 "zpool detach $MPOOL $VDEV4"
105 run_and_verify
-p "$MPOOL" \
106 -e "sysevent.fs.zfs.vdev_attach" \
107 -e "sysevent.fs.zfs.resilver_start" \
108 -e "sysevent.fs.zfs.resilver_finish" \
109 -e "sysevent.fs.zfs.config_sync" \
110 "zpool replace -f $MPOOL $VDEV1 $VDEV4"
113 run_and_verify
-p "$MPOOL" \
114 -e "sysevent.fs.zfs.scrub_start" \
115 -e "sysevent.fs.zfs.scrub_finish" \
118 # Export then import a pool (may change to a pool_export event)
119 run_and_verify
-p "$MPOOL" \
120 -e "sysevent.fs.zfs.pool_destroy" \
121 -e "sysevent.fs.zfs.config_sync" \
122 "zpool export $MPOOL"
123 run_and_verify
-p "$MPOOL" \
124 -e "sysevent.fs.zfs.pool_import" \
125 -e "sysevent.fs.zfs.config_sync" \
126 "zpool import -d $TEST_BASE_DIR $MPOOL"
129 run_and_verify
-p "$MPOOL" \
130 -e "sysevent.fs.zfs.pool_destroy" \
131 -e "sysevent.fs.zfs.config_sync" \
132 "zpool destroy $MPOOL"
134 log_pass
"Verify zpool sub-commands generate expected events"