Skip to content

Commit 53a8cbd

Browse files
ofaalandtonyhutter
authored andcommitted
Fix ZTS MMP tests and ztest -M behavior
Quote "$MMP_IMPORT_MSG" when it is passed as an argument, as it is a multi-word string. Some tests were passing when they should not have, because the grep was only testing for the first word. Correct the message expected when no hostid is set and the test attempts to enable multihost. It did not match the actual output in that situation. Disable ztest_reguid() when ztest is invoked with the -M option. If ztest performs a reguid, a concurrent import attempt may fail with the error "one or more devices is currently unavailable" if the guid sum is calculated on the original device guids but compared against the guid sum ztest wrote based on the new device guids. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Olaf Faaland <[email protected]> Closes #6666
1 parent 505b97a commit 53a8cbd

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

cmd/ztest/ztest.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5665,6 +5665,9 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id)
56655665
uint64_t orig, load;
56665666
int error;
56675667

5668+
if (ztest_opts.zo_mmp_test)
5669+
return;
5670+
56685671
orig = spa_guid(spa);
56695672
load = spa_load_guid(spa);
56705673

tests/zfs-tests/tests/functional/mmp/mmp_active_import.ksh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ log_must is_pool_imported $MMP_POOL "-d $MMP_DIR"
6060

6161
# 3. Verify 'zpool import [-f] $MMP_POOL' cannot import the pool.
6262
MMP_IMPORTED_MSG="Cannot import '$MMP_POOL': pool is imported"
63-
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" $MMP_IMPORTED_MSG
63+
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
6464
for i in {1..10}; do
65-
log_must pgrep ztest >/dev/null
66-
log_must try_pool_import $MMP_POOL "-f -d $MMP_DIR" $MMP_IMPORTED_MSG
65+
log_must try_pool_import $MMP_POOL "-f -d $MMP_DIR" "$MMP_IMPORTED_MSG"
6766
done
6867

6968
# 4. Kill ztest to make pool eligible for import. Poll with 'zpool status'.
@@ -79,21 +78,21 @@ log_must wait_pool_imported $MMP_POOL "-d $MMP_DIR"
7978
# - hostid=different - previously imported on a different system
8079
#
8180
log_must mmp_clear_hostid
82-
MMP_IMPORTED_MSG="Set the system hostid"
83-
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "action" $MMP_IMPORTED_MSG
81+
MMP_IMPORTED_MSG="Set a unique system hostid"
82+
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "action" "$MMP_IMPORTED_MSG"
8483

8584
log_must mmp_set_hostid $HOSTID1
8685
MMP_IMPORTED_MSG="The pool can be imported"
87-
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "action" $MMP_IMPORTED_MSG
86+
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "action" "$MMP_IMPORTED_MSG"
8887

8988
log_must mmp_clear_hostid
9089
log_must mmp_set_hostid $HOSTID2
9190
MMP_IMPORTED_MSG="The pool was last accessed by another system."
92-
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "status" $MMP_IMPORTED_MSG
91+
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "status" "$MMP_IMPORTED_MSG"
9392

9493
# 6. Verify 'zpool import $MMP_POOL' fails with the expected message.
9594
MMP_IMPORTED_MSG="pool was previously in use from another system."
96-
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" $MMP_IMPORTED_MSG
95+
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
9796

9897
# 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
9998
log_must import_activity_check $MMP_POOL "-f -d $MMP_DIR"

tests/zfs-tests/tests/functional/mmp/mmp_exported_import.ksh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ log_must zpool export $TESTPOOL
9898
log_must mmp_clear_hostid
9999

100100
for opt in "" "-f"; do
101-
MMP_IMPORTED_MSG="Set the system hostid"
102-
log_must check_pool_import $TESTPOOL "" "action" $MMP_IMPORTED_MSG
101+
MMP_IMPORTED_MSG="Set a unique system hostid"
102+
log_must check_pool_import $TESTPOOL "" "action" "$MMP_IMPORTED_MSG"
103103
log_mustnot import_no_activity_check $TESTPOOL $opt
104104
done
105105

tests/zfs-tests/tests/functional/mmp/mmp_inactive_import.ksh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ log_must import_activity_check $TESTPOOL "-f"
9090
# 7. Verify multihost=on and hostid zero fails (no activity check)
9191
log_must zpool export -F $TESTPOOL
9292
log_must mmp_clear_hostid
93-
MMP_IMPORTED_MSG="Set the system hostid"
94-
log_must check_pool_import $TESTPOOL "-f" "action" $MMP_IMPORTED_MSG
93+
MMP_IMPORTED_MSG="Set a unique system hostid"
94+
log_must check_pool_import $TESTPOOL "-f" "action" "$MMP_IMPORTED_MSG"
9595
log_mustnot import_no_activity_check $TESTPOOL "-f"
9696

9797
log_pass "multihost=on|off inactive pool activity checks passed"

0 commit comments

Comments
 (0)