1#!/bin/ksh -p 2 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright (c) 2021 by Delphix. All rights reserved. 16# Copyright (c) 2023 by Klara, Inc. 17# 18 19. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib 20 21# 22# DESCRIPTION: 23# A pool that was cleanly exported should be importable from a cachefile 24# without force even if the local hostid doesn't match the on-disk hostid. 25# 26# STRATEGY: 27# 1. Set a hostid. 28# 2. Create a pool with a cachefile. 29# 3. Backup the cachfile. 30# 4. Export the pool. 31# 5. Change the hostid. 32# 6. Verify that importing the pool from the cachefile succeeds 33# without force. 34# 35 36verify_runnable "global" 37 38function custom_cleanup 39{ 40 rm -f $HOSTID_FILE $CPATH $CPATHBKP 41 cleanup 42} 43 44log_onexit custom_cleanup 45 46# 1. Set a hostid. 47log_must zgenhostid -f $HOSTID1 48 49# 2. Create a pool. 50log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $VDEV0 51 52# 3. Backup the cachfile. 53log_must cp $CPATH $CPATHBKP 54 55# 4. Export the pool. 56log_must zpool export $TESTPOOL1 57 58# 5. Change the hostid. 59log_must zgenhostid -f $HOSTID2 60 61# 6. Verify that importing the pool from the cachefile succeeds without force. 62log_must zpool import -c $CPATHBKP $TESTPOOL1 63 64log_pass "zpool import can import cleanly exported pool from cachefile " \ 65 "when hostid changes." 66