]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_labelclear / zpool_labelclear_active.ksh
1 #!/bin/ksh -p
2 #
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source.  A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13
14 #
15 # Copyright 2016 Nexenta Systems, Inc.
16 #
17
18 . $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg
19
20 # DESCRIPTION:
21 # Check that zpool labelclear will refuse to clear the label
22 # (with or without -f) on any vdevs of the imported pool.
23 #
24 # STRATEGY:
25 # 1. Create the pool with log device.
26 # 2. Try clearing the label on data and log devices.
27 # 3. Add auxiliary (cache/spare) vdevs.
28 # 4. Try clearing the label on auxiliary vdevs.
29 # 5. Check that zpool labelclear will return non-zero and
30 #    labels are intact.
31
32 verify_runnable "global"
33
34 function cleanup
35 {
36         poolexists $TESTPOOL && destroy_pool $TESTPOOL
37 }
38
39 log_onexit cleanup
40 log_assert "zpool labelclear will fail on all vdevs of imported pool"
41
42 # Create simple pool, skip any mounts
43 log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2
44
45 # Check that labelclear [-f] will fail on ACTIVE pool vdevs
46 log_mustnot zpool labelclear $disk1
47 log_must zdb -lq $disk1
48 log_mustnot zpool labelclear -f $disk1
49 log_must zdb -lq $disk1
50 log_mustnot zpool labelclear $disk2
51 log_must zdb -lq $disk2
52 log_mustnot zpool labelclear -f $disk2
53 log_must zdb -lq $disk2
54
55 # Add a cache/spare to the pool, check that labelclear [-f] will fail
56 # on the vdev and will succeed once it's removed from pool config
57 for vdevtype in "cache" "spare"; do
58         log_must zpool add $TESTPOOL $vdevtype $disk3
59         log_mustnot zpool labelclear $disk3
60         log_must zdb -lq $disk3
61         log_mustnot zpool labelclear -f $disk3
62         log_must zdb -lq $disk3
63         log_must zpool remove $TESTPOOL $disk3
64         log_must zpool labelclear $disk3
65         log_mustnot zdb -lq $disk3
66 done
67
68 log_pass "zpool labelclear will fail on all vdevs of imported pool"