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 40verify_runnable "both" 41 42function cleanup 43{ 44 default_cleanup_noexit 45 log_must mmp_clear_hostid 46 log_must set_tunable64 MULTIHOST_INTERVAL $MMP_INTERVAL_DEFAULT 47} 48 49log_assert "multihost=on|off inactive pool activity checks" 50log_onexit cleanup 51 52# 1. Create a zpool 53log_must mmp_set_hostid $HOSTID1 54default_setup_noexit $DISK 55 56# 2. Verify multihost=off and hostids match (no activity check) 57log_must zpool set multihost=off $TESTPOOL 58 59for opt in "" "-f"; do 60 log_must zpool export -F $TESTPOOL 61 log_must import_no_activity_check $TESTPOOL $opt 62done 63 64# 3. Verify multihost=off and hostids differ (no activity check) 65log_must zpool export -F $TESTPOOL 66log_must mmp_clear_hostid 67log_must mmp_set_hostid $HOSTID2 68log_mustnot import_no_activity_check $TESTPOOL "" 69log_must import_no_activity_check $TESTPOOL "-f" 70 71# 4. Verify multihost=off and hostid zero allowed (no activity check) 72log_must zpool export -F $TESTPOOL 73log_must mmp_clear_hostid 74log_mustnot import_no_activity_check $TESTPOOL "" 75log_must import_no_activity_check $TESTPOOL "-f" 76 77# 5. Verify multihost=on and hostids match (no activity check) 78log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1 79log_must zpool set multihost=on $TESTPOOL 80 81for opt in "" "-f"; do 82 log_must zpool export -F $TESTPOOL 83 log_must import_no_activity_check $TESTPOOL $opt 84done 85 86# 6. Verify multihost=on and hostids differ (activity check) 87log_must zpool export -F $TESTPOOL 88log_must mmp_clear_hostid 89log_must mmp_set_hostid $HOSTID2 90log_mustnot import_activity_check $TESTPOOL "" 91log_must import_activity_check $TESTPOOL "-f" 92 93# 7. Verify mmp_write and mmp_fail are set correctly 94log_must zpool export -F $TESTPOOL 95log_must verify_mmp_write_fail_present ${DISK[0]} 96 97# 8. Verify multihost=on and hostid zero fails (no activity check) 98log_must mmp_clear_hostid 99MMP_IMPORTED_MSG="Set a unique system hostid" 100log_must check_pool_import $TESTPOOL "-f" "action" "$MMP_IMPORTED_MSG" 101log_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. 106log_must set_tunable64 MULTIHOST_INTERVAL $MMP_INTERVAL_MIN 107log_must mmp_clear_hostid 108log_must mmp_set_hostid $HOSTID1 109log_must import_activity_check $TESTPOOL "-f" $MMP_TEST_DURATION_DEFAULT 110 111log_pass "multihost=on|off inactive pool activity checks passed" 112