]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/mmp/mmp_inactive_import.ksh
MMP interval and fail_intervals in uberblock
[mirror_zfs.git] / tests / zfs-tests / tests / functional / mmp / mmp_inactive_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 inactive, but not exported, pools
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 allowed (no activity check)
29 # 5. Verify multihost=on and hostids match (no activity check)
30 # 6. Verify multihost=on and hostids differ (activity check)
31 # 7. Verify mmp_write and mmp_fail are set correctly
32 # 8. Verify multihost=on and hostid zero fails (no activity check)
33 # 9. Verify activity check duration based on mmp_write and mmp_fail
34 #
35
36 . $STF_SUITE/include/libtest.shlib
37 . $STF_SUITE/tests/functional/mmp/mmp.cfg
38 . $STF_SUITE/tests/functional/mmp/mmp.kshlib
39
40 verify_runnable "both"
41
42 function cleanup
43 {
44 default_cleanup_noexit
45 log_must mmp_clear_hostid
46 log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_DEFAULT
47 }
48
49 log_assert "multihost=on|off inactive pool activity checks"
50 log_onexit cleanup
51
52 # 1. Create a zpool
53 log_must mmp_set_hostid $HOSTID1
54 default_setup_noexit $DISK
55
56 # 2. Verify multihost=off and hostids match (no activity check)
57 log_must zpool set multihost=off $TESTPOOL
58
59 for opt in "" "-f"; do
60 log_must zpool export -F $TESTPOOL
61 log_must import_no_activity_check $TESTPOOL $opt
62 done
63
64 # 3. Verify multihost=off and hostids differ (no activity check)
65 log_must zpool export -F $TESTPOOL
66 log_must mmp_clear_hostid
67 log_must mmp_set_hostid $HOSTID2
68 log_mustnot import_no_activity_check $TESTPOOL ""
69 log_must import_no_activity_check $TESTPOOL "-f"
70
71 # 4. Verify multihost=off and hostid zero allowed (no activity check)
72 log_must zpool export -F $TESTPOOL
73 log_must mmp_clear_hostid
74 log_mustnot import_no_activity_check $TESTPOOL ""
75 log_must import_no_activity_check $TESTPOOL "-f"
76
77 # 5. Verify multihost=on and hostids match (no activity check)
78 log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
79 log_must zpool set multihost=on $TESTPOOL
80
81 for opt in "" "-f"; do
82 log_must zpool export -F $TESTPOOL
83 log_must import_no_activity_check $TESTPOOL $opt
84 done
85
86 # 6. Verify multihost=on and hostids differ (activity check)
87 log_must zpool export -F $TESTPOOL
88 log_must mmp_clear_hostid
89 log_must mmp_set_hostid $HOSTID2
90 log_mustnot import_activity_check $TESTPOOL ""
91 log_must import_activity_check $TESTPOOL "-f"
92
93 # 7. Verify mmp_write and mmp_fail are set correctly
94 log_must zpool export -F $TESTPOOL
95 log_must verify_mmp_write_fail_present ${DISK[0]}
96
97 # 8. Verify multihost=on and hostid zero fails (no activity check)
98 log_must mmp_clear_hostid
99 MMP_IMPORTED_MSG="Set a unique system hostid"
100 log_must check_pool_import $TESTPOOL "-f" "action" "$MMP_IMPORTED_MSG"
101 log_mustnot import_no_activity_check $TESTPOOL "-f"
102
103 # 9. Verify activity check duration based on mmp_write and mmp_fail
104 # Specify a short test via tunables but import pool imported while
105 # tunables set to default duration.
106 log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_MIN
107 log_must mmp_clear_hostid
108 log_must mmp_set_hostid $HOSTID1
109 log_must import_activity_check $TESTPOOL "-f" $MMP_TEST_DURATION_DEFAULT
110
111 log_pass "multihost=on|off inactive pool activity checks passed"