]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_003_pos.ksh
Remove races from scrub / resilver tests
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_import / zpool_import_features_003_pos.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) 2012, 2016 by Delphix. All rights reserved.
25 #
26
27 . $STF_SUITE/include/libtest.shlib
28 . $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
29
30 #################################################################################
31 #
32 #  Pool can be imported with active read-only compatible features. If a feature
33 #  is read-only compatible but also inactive its property status should be
34 #  "inactive" rather than "readonly".
35 #
36 #  1. Create new pool.
37 #  2. Export and inject variety of unsupported features.
38 #  3. Try to import read-write, this should fail. The error should only list
39 #     the active read-only compatible feature and mention "readonly=on".
40 #  4. Import the pool in read-only mode.
41 #  5. Verify values of unsupported@ properties.
42 #
43 ################################################################################
44
45 verify_runnable "global"
46
47 enabled_features="com.test:xxx_unsup0 com.test:xxx_unsup2"
48 active_features="com.test:xxx_unsup1 com.test:xxx_unsup3"
49
50 function cleanup
51 {
52         poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
53
54         log_must rm $VDEV0
55         log_must mkfile $FILE_SIZE $VDEV0
56 }
57
58 log_assert "Pool with active read-only compatible features can be imported."
59 log_onexit cleanup
60
61 log_must zpool create $TESTPOOL1 $VDEV0
62 log_must zpool export $TESTPOOL1
63
64 for feature in $enabled_features $active_features; do
65         log_must zhack -d $DEVICE_DIR feature enable -r $TESTPOOL1 $feature
66 done
67
68 for feature in $active_features; do
69         log_must zhack -d $DEVICE_DIR feature ref $TESTPOOL1 $feature
70 done
71
72 log_mustnot zpool import -d $DEVICE_DIR $TESTPOOL1
73
74 # error message should mention "readonly"
75 log_must eval "zpool import -d $DEVICE_DIR $TESTPOOL1 | grep readonly"
76 log_mustnot poolexists $TESTPOOL1
77
78 for feature in $enabled_features; do
79         log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \
80             | grep $feature"
81         log_mustnot poolexists $TESTPOOL1
82 done
83
84 for feature in $active_features; do
85         log_must eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \
86             | grep $feature"
87         log_mustnot poolexists $TESTPOOL1
88 done
89
90 log_must zpool import -o readonly=on -d $DEVICE_DIR $TESTPOOL1
91
92 for feature in $enabled_features; do
93         state=$(zpool list -Ho unsupported@$feature $TESTPOOL1)
94         if [[ "$state" != "inactive" ]]; then
95                 log_fail "unsupported@$feature is '$state'"
96         fi
97 done
98
99 for feature in $active_features; do
100         state=$(zpool list -Ho unsupported@$feature $TESTPOOL1)
101         if [[ "$state" != "readonly" ]]; then
102                 log_fail "unsupported@$feature is '$state'"
103         fi
104 done
105
106 log_pass