mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
tests: add tests for zpool import behaviour when hostid changes
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #15290
This commit is contained in:
parent
5b8688e620
commit
8f5aa8cb00
@ -415,6 +415,10 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos',
|
||||
'zpool_import_rename_001_pos', 'zpool_import_all_001_pos',
|
||||
'zpool_import_encrypted', 'zpool_import_encrypted_load',
|
||||
'zpool_import_errata3', 'zpool_import_errata4',
|
||||
'zpool_import_hostid_changed',
|
||||
'zpool_import_hostid_changed_unclean_export',
|
||||
'zpool_import_hostid_changed_cachefile',
|
||||
'zpool_import_hostid_changed_cachefile_unclean_export',
|
||||
'import_cachefile_device_added',
|
||||
'import_cachefile_device_removed',
|
||||
'import_cachefile_device_replaced',
|
||||
|
@ -1104,6 +1104,10 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/cli_root/zpool_import/zpool_import_features_001_pos.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_features_003_pos.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_hostid_changed.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_hostid_changed_unclean_export.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_missing_002_pos.ksh \
|
||||
functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh \
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#
|
||||
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2023 by Klara, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@ -63,3 +64,7 @@ export VDEV4=$DEVICE_DIR/${DEVICE_FILE}4
|
||||
export VDEV5=$DEVICE_DIR/${DEVICE_FILE}5
|
||||
|
||||
export ALTER_ROOT=/alter_import-test
|
||||
|
||||
export HOSTID_FILE="/etc/hostid"
|
||||
export HOSTID1=01234567
|
||||
export HOSTID2=89abcdef
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#
|
||||
# Copyright (c) 2016 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2023 by Klara, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
@ -0,0 +1,59 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2023 by Klara, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# A pool that was cleanly exported should be importable without force even if
|
||||
# the local hostid doesn't match the on-disk hostid.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set a hostid.
|
||||
# 2. Create a pool.
|
||||
# 3. Export the pool.
|
||||
# 4. Change the hostid.
|
||||
# 5. Verify that importing the pool without force succeeds.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function custom_cleanup
|
||||
{
|
||||
rm -f $HOSTID_FILE
|
||||
cleanup
|
||||
}
|
||||
|
||||
log_onexit custom_cleanup
|
||||
|
||||
# 1. Set a hostid.
|
||||
log_must zgenhostid -f $HOSTID1
|
||||
|
||||
# 2. Create a pool.
|
||||
log_must zpool create $TESTPOOL1 $VDEV0
|
||||
|
||||
# 3. Export the pool.
|
||||
log_must zpool export $TESTPOOL1
|
||||
|
||||
# 4. Change the hostid.
|
||||
log_must zgenhostid -f $HOSTID2
|
||||
|
||||
# 5. Verify that importing the pool without force succeeds.
|
||||
log_must zpool import -d $DEVICE_DIR $TESTPOOL1
|
||||
|
||||
log_pass "zpool import can import cleanly exported pool when hostid changes."
|
@ -0,0 +1,65 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2023 by Klara, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# A pool that was cleanly exported should be importable from a cachefile
|
||||
# without force even if the local hostid doesn't match the on-disk hostid.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set a hostid.
|
||||
# 2. Create a pool with a cachefile.
|
||||
# 3. Backup the cachfile.
|
||||
# 4. Export the pool.
|
||||
# 5. Change the hostid.
|
||||
# 6. Verify that importing the pool from the cachefile succeeds
|
||||
# without force.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function custom_cleanup
|
||||
{
|
||||
rm -f $HOSTID_FILE $CPATH $CPATHBKP
|
||||
cleanup
|
||||
}
|
||||
|
||||
log_onexit custom_cleanup
|
||||
|
||||
# 1. Set a hostid.
|
||||
log_must zgenhostid -f $HOSTID1
|
||||
|
||||
# 2. Create a pool.
|
||||
log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $VDEV0
|
||||
|
||||
# 3. Backup the cachfile.
|
||||
log_must cp $CPATH $CPATHBKP
|
||||
|
||||
# 4. Export the pool.
|
||||
log_must zpool export $TESTPOOL1
|
||||
|
||||
# 5. Change the hostid.
|
||||
log_must zgenhostid -f $HOSTID2
|
||||
|
||||
# 6. Verify that importing the pool from the cachefile succeeds without force.
|
||||
log_must zpool import -c $CPATHBKP $TESTPOOL1
|
||||
|
||||
log_pass "zpool import can import cleanly exported pool from cachefile " \
|
||||
"when hostid changes."
|
@ -0,0 +1,71 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2023 by Klara, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# A pool that wasn't cleanly exported should be importable from a cachefile
|
||||
# without force even if the local hostid doesn't match the on-disk hostid.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set a hostid.
|
||||
# 2. Create a pool.
|
||||
# 3. Backup the cachefile.
|
||||
# 4. Simulate the pool being torn down without export:
|
||||
# 4.1. Copy the underlying device state.
|
||||
# 4.2. Export the pool.
|
||||
# 4.3. Restore the device state from the copy.
|
||||
# 5. Change the hostid.
|
||||
# 6. Verify that importing the pool from the cachefile succeeds
|
||||
# without force.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function custom_cleanup
|
||||
{
|
||||
rm -f $HOSTID_FILE $CPATH $CPATHBKP $VDEV0.bak
|
||||
cleanup
|
||||
}
|
||||
|
||||
log_onexit custom_cleanup
|
||||
|
||||
# 1. Set a hostid.
|
||||
log_must zgenhostid -f $HOSTID1
|
||||
|
||||
# 2. Create a pool.
|
||||
log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $VDEV0
|
||||
|
||||
# 3. Backup the cachfile.
|
||||
log_must cp $CPATH $CPATHBKP
|
||||
|
||||
# 4. Simulate the pool being torn down without export.
|
||||
log_must cp $VDEV0 $VDEV0.bak
|
||||
log_must zpool export $TESTPOOL1
|
||||
log_must cp -f $VDEV0.bak $VDEV0
|
||||
log_must rm -f $VDEV0.bak
|
||||
|
||||
# 5. Change the hostid.
|
||||
log_must zgenhostid -f $HOSTID2
|
||||
|
||||
# 6. Verify that importing the pool from the cachefile succeeds without force.
|
||||
log_must zpool import -c $CPATHBKP $TESTPOOL1
|
||||
|
||||
log_pass "zpool import can import pool from cachefile if not cleanly " \
|
||||
"exported when hostid changes."
|
@ -0,0 +1,70 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2023 by Klara, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# A pool that wasn't cleanly exported should not be importable without force if
|
||||
# the local hostid doesn't match the on-disk hostid.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set a hostid.
|
||||
# 2. Create a pool.
|
||||
# 3. Simulate the pool being torn down without export:
|
||||
# 3.1. Copy the underlying device state.
|
||||
# 3.2. Export the pool.
|
||||
# 3.3. Restore the device state from the copy.
|
||||
# 4. Change the hostid.
|
||||
# 5. Verify that importing the pool fails.
|
||||
# 6. Verify that importing the pool with force succeeds.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function custom_cleanup
|
||||
{
|
||||
rm -f $HOSTID_FILE $VDEV0.bak
|
||||
cleanup
|
||||
}
|
||||
|
||||
log_onexit custom_cleanup
|
||||
|
||||
# 1. Set a hostid.
|
||||
log_must zgenhostid -f $HOSTID1
|
||||
|
||||
# 2. Create a pool.
|
||||
log_must zpool create $TESTPOOL1 $VDEV0
|
||||
|
||||
# 3. Simulate the pool being torn down without export.
|
||||
log_must cp $VDEV0 $VDEV0.bak
|
||||
log_must zpool export $TESTPOOL1
|
||||
log_must cp -f $VDEV0.bak $VDEV0
|
||||
log_must rm -f $VDEV0.bak
|
||||
|
||||
# 4. Change the hostid.
|
||||
log_must zgenhostid -f $HOSTID2
|
||||
|
||||
# 5. Verify that importing the pool fails.
|
||||
log_mustnot zpool import -d $DEVICE_DIR $TESTPOOL1
|
||||
|
||||
# 6. Verify that importing the pool with force succeeds.
|
||||
log_must zpool import -d $DEVICE_DIR -f $TESTPOOL1
|
||||
|
||||
log_pass "zpool import requires force if not cleanly exported " \
|
||||
"and hostid changed."
|
Loading…
Reference in New Issue
Block a user