]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/mmp/mmp_exported_import.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / mmp / mmp_exported_import.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
8 # 1.0 of the CDDL.
9 #
10 # A full copy of the text of the CDDL should have accompanied this
11 # source.  A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
13 #
14 # CDDL HEADER END
15 #
16
17 #
18 # Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
19 #
20
21 # DESCRIPTION:
22 #       Verify import behavior for exported pool (no activity check)
23 #
24 # STRATEGY:
25 #       1. Create a zpool
26 #       2. Verify multihost=off and hostids match (no activity check)
27 #       3. Verify multihost=off and hostids differ (no activity check)
28 #       4. Verify multihost=off and hostid zero allowed (no activity check)
29 #       5. Verify multihost=on and hostids match (no activity check)
30 #       6. Verify multihost=on and hostids differ (no activity check)
31 #       7. Verify multihost=on and hostid zero fails (no activity check)
32 #
33
34 . $STF_SUITE/include/libtest.shlib
35 . $STF_SUITE/tests/functional/mmp/mmp.cfg
36 . $STF_SUITE/tests/functional/mmp/mmp.kshlib
37
38 verify_runnable "both"
39
40 function cleanup
41 {
42         default_cleanup_noexit
43         log_must mmp_clear_hostid
44 }
45
46 log_assert "multihost=on|off activity checks exported pool"
47 log_onexit cleanup
48
49 # 1. Create a zpool
50 log_must mmp_set_hostid $HOSTID1
51 default_setup_noexit $DISK
52
53 # 2. Verify multihost=off and hostids match (no activity check)
54 log_must zpool set multihost=off $TESTPOOL
55
56 for opt in "" "-f"; do
57         log_must zpool export $TESTPOOL
58         log_must import_no_activity_check $TESTPOOL $opt
59 done
60
61 # 3. Verify multihost=off and hostids differ (no activity check)
62 for opt in "" "-f"; do
63         log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
64         log_must zpool export $TESTPOOL
65         log_must mmp_clear_hostid
66         log_must mmp_set_hostid $HOSTID2
67         log_must import_no_activity_check $TESTPOOL $opt
68 done
69
70 # 4. Verify multihost=off and hostid zero allowed (no activity check)
71 log_must mmp_clear_hostid
72
73 for opt in "" "-f"; do
74         log_must zpool export $TESTPOOL
75         log_must import_no_activity_check $TESTPOOL $opt
76 done
77
78 # 5. Verify multihost=on and hostids match (no activity check)
79 log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
80 log_must zpool set multihost=on $TESTPOOL
81
82 for opt in "" "-f"; do
83         log_must zpool export $TESTPOOL
84         log_must import_no_activity_check $TESTPOOL $opt
85 done
86
87 # 6. Verify multihost=on and hostids differ (no activity check)
88 for opt in "" "-f"; do
89         log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
90         log_must zpool export $TESTPOOL
91         log_must mmp_clear_hostid
92         log_must mmp_set_hostid $HOSTID2
93         log_must import_no_activity_check $TESTPOOL $opt
94 done
95
96 # 7. Verify multihost=on and hostid zero fails (no activity check)
97 log_must zpool export $TESTPOOL
98 log_must mmp_clear_hostid
99
100 for opt in "" "-f"; do
101         MMP_IMPORTED_MSG="Set a unique system hostid"
102         log_must check_pool_import $TESTPOOL "" "action" "$MMP_IMPORTED_MSG"
103         log_mustnot import_no_activity_check $TESTPOOL $opt
104 done
105
106 log_pass "multihost=on|off exported pool activity checks passed"