xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/mmp/mmp_inactive_import.ksh (revision 35c005f243fafd7cad624b8a3a64298cab8ac172)
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# Copyright 2019 Joyent, Inc.
20#
21
22# DESCRIPTION:
23#	Verify import behavior for inactive, but not exported, pools
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 allowed (no activity check)
30#	5. Verify multihost=on and hostids match (no activity check)
31#	6. Verify multihost=on and hostids differ (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 inactive pool activity checks"
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 -F $TESTPOOL
59	log_must import_no_activity_check $TESTPOOL $opt
60done
61
62# 3. Verify multihost=off and hostids differ (no activity check)
63log_must zpool export -F $TESTPOOL
64log_must mmp_clear_hostid
65log_must mmp_set_hostid $HOSTID2
66log_mustnot import_no_activity_check $TESTPOOL ""
67log_must import_no_activity_check $TESTPOOL "-f"
68
69# 4. Verify multihost=off and hostid zero allowed (no activity check)
70log_must zpool export -F $TESTPOOL
71log_must mmp_clear_hostid
72log_mustnot import_no_activity_check $TESTPOOL ""
73log_must import_no_activity_check $TESTPOOL "-f"
74
75# 5. Verify multihost=on and hostids match (no activity check)
76log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
77log_must zpool set multihost=on $TESTPOOL
78
79for opt in "" "-f"; do
80	log_must zpool export -F $TESTPOOL
81	log_must import_no_activity_check $TESTPOOL $opt
82done
83
84# 6. Verify multihost=on and hostids differ (activity check)
85log_must zpool export -F $TESTPOOL
86log_must mmp_clear_hostid
87log_must mmp_set_hostid $HOSTID2
88log_mustnot import_activity_check $TESTPOOL ""
89log_must import_activity_check $TESTPOOL "-f"
90
91# 7. Verify multihost=on and hostid zero fails (no activity check)
92log_must zpool export -F $TESTPOOL
93log_must mmp_clear_hostid
94case "$(uname)" in
95Linux)	MMP_IMPORTED_MSG="Set a unique system hostid";;
96SunOS)	MMP_IMPORTED_MSG="Check the SMF svc:/system/hostid service.";;
97esac
98log_must check_pool_import $TESTPOOL "-f" "action" "$MMP_IMPORTED_MSG"
99log_mustnot import_no_activity_check $TESTPOOL "-f"
100
101log_pass "multihost=on|off inactive pool activity checks passed"
102