From ab1b87e7479b6a615d7882de0579c9085eeaebac Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 26 Sep 2024 09:58:11 -0700 Subject: [PATCH] ZTS: Fix zpool_import_hostid_changed_cachefile_unclean_export Update the test case to freeze the pool then export it to better simulate a hard failure. This is preferable to copying the vdev while the pool's imported since with a copy we're not guaranteed the on-disk state will be consistent. That can in turn result in a pool import failure and a spurious test failure. Reviewed-by: Alexander Motin Signed-off-by: Brian Behlendorf Closes #16570 --- .../zpool_import_hostid_changed_cachefile_unclean_export.ksh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh index dcb1ac1ab..c4273d050 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_hostid_changed_cachefile_unclean_export.ksh @@ -28,9 +28,8 @@ # 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. +# 4.1. Sync then freeze the pool. +# 4.2. Export the pool (uncleanly). # 5. Change the hostid. # 6. Verify that importing the pool from the cachefile fails. # 7. Verify that importing the pool from the cachefile with force @@ -57,10 +56,9 @@ log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $VDEV0 log_must cp $CPATH $CPATHBKP # 4. Simulate the pool being torn down without export. -log_must cp $VDEV0 $VDEV0.bak +sync_pool $TESTPOOL1 +log_must zpool freeze $TESTPOOL1 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 -- 2.11.4.GIT