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