Skip to content

Commit e582885

Browse files
committed
ZTS: update the relevant mmp test cases
- mmp_concurrent_import: added test case to verify that concurrent import correctness. The pool may only be imported once. - mmp_exported_import: an activity check is now required for pools which were cleanly exported if the system and pool hostids don't match. - mmp_inactive_import: an activity check is now required for any pool which wasn't cleanly exported, even if the system and pool hostids match. - mmp_on_uberblocks: updated expected uberblocks to take in to account the value MMP_INTERVAL_DEFAULT is set too. - mmp_reset_interval: reduce the number of iterations from 10 to 3. This is sufficient to verify functionality and significantly speeds up the test. - mmp_on_uberblocks: adjust the thresholds and increase the runtime to avoid false positives observed in CI. - Update tests to use 'zhack action idle' instead of ztest to improve the reliability of the tests. - Add additional log_note messages to test cases which have multiple verification steps to make it clear which portion of a test failed when reviewing the logs. - Replace default_setup/cleanup_noexit calls with 'zpool create' and 'zpool destroy' calls to avoid additional unnecessary dataset creation work. - Update activity/noactivity check helper functions to use the ZFS_LOAD_INFO_DEBUG information now available from 'zpool import' to determine if this activity check ran and why. This is more reliable in the CI than measuring the runtime. - Removed all mmp tests from the zts-report.py exceptions list. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
1 parent 4fe5e29 commit e582885

21 files changed

+252
-81
lines changed

module/zfs/spa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4099,8 +4099,8 @@ spa_activity_check_tryimport(spa_t *spa, uberblock_t *spa_ub,
40994099
hrtime_t extra_delay = MMP_IMPORT_VERIFY_ITERS *
41004100
MSEC2NSEC(MMP_INTERVAL_VALID(spa_ub) ?
41014101
MMP_INTERVAL(spa_ub) : MMP_MIN_INTERVAL);
4102-
cmn_err(CE_NOTE, "pool '%s' multihost activity check "
4103-
"required, %llu seconds remaining", spa_load_name(spa),
4102+
cmn_err(CE_NOTE, "pool '%s' activity check required, "
4103+
"%llu seconds remaining", spa_load_name(spa),
41044104
(u_longlong_t)MAX(NSEC2SEC(import_delay + extra_delay), 1));
41054105
spa_import_progress_set_notes(spa, "Checking MMP activity, "
41064106
"waiting %llu ms", (u_longlong_t)NSEC2MSEC(import_delay));

tests/runfiles/linux.run

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ tags = ['functional', 'mmap']
159159
tests = ['mmp_on_thread', 'mmp_on_uberblocks', 'mmp_on_off', 'mmp_interval',
160160
'mmp_active_import', 'mmp_inactive_import', 'mmp_exported_import',
161161
'mmp_write_uberblocks', 'mmp_reset_interval', 'multihost_history',
162-
'mmp_on_zdb', 'mmp_write_distribution', 'mmp_hostid', 'mmp_write_slow_disk']
162+
'mmp_on_zdb', 'mmp_write_distribution', 'mmp_hostid', 'mmp_write_slow_disk',
163+
'mmp_concurrent_import']
163164
tags = ['functional', 'mmp']
165+
timeout = 1200
164166

165167
[tests/functional/mount:Linux]
166168
tests = ['umount_unlinked_drain', 'mount_loopback']

tests/test-runner/bin/zts-report.py.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ maybe = {
247247
'l2arc/persist_l2arc_005_pos': ['FAIL', known_reason],
248248
'largest_pool/largest_pool_001_pos': ['FAIL', known_reason],
249249
'mmap/mmap_sync_001_pos': ['FAIL', known_reason],
250-
'mmp/mmp_on_uberblocks': ['FAIL', known_reason],
251250
'pam/setup': ['SKIP', "pamtester might be not available"],
252251
'pool_checkpoint/checkpoint_discard_busy': ['FAIL', 11946],
253252
'projectquota/setup': ['SKIP', exec_reason],
@@ -366,9 +365,6 @@ elif sys.platform.startswith('linux'):
366365
'io/io_uring': ['SKIP', 'io_uring support required'],
367366
'limits/filesystem_limit': ['SKIP', known_reason],
368367
'limits/snapshot_limit': ['SKIP', known_reason],
369-
'mmp/mmp_active_import': ['FAIL', known_reason],
370-
'mmp/mmp_exported_import': ['FAIL', known_reason],
371-
'mmp/mmp_inactive_import': ['FAIL', known_reason],
372368
'stat/statx_dioalign': ['SKIP', 'statx_reason'],
373369
})
374370

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
17191719
functional/mmap/setup.ksh \
17201720
functional/mmp/cleanup.ksh \
17211721
functional/mmp/mmp_active_import.ksh \
1722+
functional/mmp/mmp_concurrent_import.ksh \
17221723
functional/mmp/mmp_exported_import.ksh \
17231724
functional/mmp/mmp_hostid.ksh \
17241725
functional/mmp/mmp_inactive_import.ksh \

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
verify_runnable "global"
2626

27+
if [ -e $HOSTID_FILE.save ]; then
28+
mv -f ${HOSTID_FILE}.save $HOSTID_FILE
29+
fi
30+
2731
log_must set_tunable64 MULTIHOST_HISTORY $MMP_HISTORY_OFF
2832

2933
log_pass "mmp cleanup passed"

tests/zfs-tests/tests/functional/mmp/mmp.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ export DISK=${DISKS%% *}
2525
export HOSTID_FILE="/etc/hostid"
2626
export HOSTID1=01234567
2727
export HOSTID2=89abcdef
28+
export HOSTID3=aaaabbbb
29+
export HOSTID4=ccccdddd
2830

2931
export TXG_TIMEOUT_LONG=5000
3032
export TXG_TIMEOUT_DEFAULT=5
3133

3234
export MMP_POOL=mmppool
3335
export MMP_DIR=$TEST_BASE_DIR/mmp
3436
export MMP_CACHE=$MMP_DIR/zpool.cache
35-
export MMP_ZTEST_LOG=$MMP_DIR/ztest.log
37+
export MMP_ZHACK_LOG=$MMP_DIR/zhack.log
3638
export MMP_HISTORY=100
3739
export MMP_HISTORY_OFF=0
3840

@@ -43,5 +45,3 @@ export MMP_INTERVAL_MIN=100
4345
export MMP_IMPORT_INTERVALS=20
4446
export MMP_FAIL_INTERVALS_DEFAULT=10
4547
export MMP_FAIL_INTERVALS_MIN=2
46-
47-
export MMP_TEST_DURATION_DEFAULT=$((MMP_IMPORT_INTERVALS*MMP_INTERVAL_DEFAULT/1000))

tests/zfs-tests/tests/functional/mmp/mmp.kshlib

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ function mmp_pool_create_simple # pool dir
9999
log_must zpool set multihost=on $pool
100100
}
101101

102-
function mmp_pool_create # pool dir
102+
function mmp_pool_create_zhack # pool dir
103103
{
104104
typeset pool=${1:-$MMP_POOL}
105105
typeset dir=${2:-$MMP_DIR}
106-
typeset opts="-VVVVV -T120 -M -k0 -f $dir -E -p $pool"
106+
typeset opts="-d $dir action idle -t120 $pool"
107107

108108
mmp_pool_create_simple $pool $dir
109109

@@ -112,11 +112,11 @@ function mmp_pool_create # pool dir
112112
log_must mmp_clear_hostid
113113
log_must mmp_set_hostid $HOSTID2
114114

115-
log_note "Starting ztest in the background as hostid $HOSTID1"
116-
log_must eval "ZFS_HOSTID=$HOSTID1 ztest $opts >$MMP_ZTEST_LOG 2>&1 &"
115+
log_note "Starting zhack in the background as hostid $HOSTID1"
116+
log_must eval "ZFS_HOSTID=$HOSTID1 zhack $opts >$MMP_ZHACK_LOG 2>&1 &"
117117

118118
while ! is_pool_imported "$pool" "-d $dir"; do
119-
log_must pgrep ztest
119+
log_must pgrep zhack
120120
log_must sleep 5
121121
done
122122
}
@@ -126,10 +126,10 @@ function mmp_pool_destroy # pool dir
126126
typeset pool=${1:-$MMP_POOL}
127127
typeset dir=${2:-$MMP_DIR}
128128

129-
ZTESTPID=$(pgrep ztest)
130-
if [ -n "$ZTESTPID" ]; then
131-
log_must kill $ZTESTPID
132-
wait $ZTESTPID
129+
ZHACKPID=$(pgrep zhack)
130+
if [ -n "$ZHACKPID" ]; then
131+
log_must kill $ZHACKPID
132+
wait $ZHACKPID
133133
fi
134134

135135
if poolexists $pool; then
@@ -158,33 +158,34 @@ function import_no_activity_check # pool opts
158158
typeset pool=$1
159159
typeset opts=$2
160160

161-
typeset max_duration=$((MMP_TEST_DURATION_DEFAULT-1))
162-
163-
SECONDS=0
164-
zpool import $opts $pool
161+
RESULT=$(ZFS_LOAD_INFO_DEBUG=1 zpool import $opts $pool)
165162
typeset rc=$?
166163

167-
if [[ $SECONDS -gt $max_duration ]]; then
168-
log_fail "ERROR: import_no_activity_check unexpected activity \
169-
check (${SECONDS}s gt $max_duration)"
164+
# mmp_result: 3 (ESRCH) no activity check was run not required
165+
# mmp_result: 6 (ENXIO) no activity check was run hostid not set
166+
if ! echo "$RESULT" | grep -q "mmp_result: 3" &&
167+
! echo "$RESULT" | grep -q "mmp_result: 6"; then
168+
log_note "ERROR: $RESULT"
169+
log_fail "ERROR: import_no_activity_check unexpected activity check"
170170
fi
171171

172172
return $rc
173173
}
174174

175-
function import_activity_check # pool opts act_test_duration
175+
function import_activity_check # pool opts
176176
{
177177
typeset pool=$1
178178
typeset opts=$2
179-
typeset min_duration=${3:-$MMP_TEST_DURATION_DEFAULT}
180179

181-
SECONDS=0
182-
zpool import $opts $pool
180+
RESULT=$(ZFS_LOAD_INFO_DEBUG=1 zpool import $opts $pool)
183181
typeset rc=$?
184182

185-
if [[ $SECONDS -le $min_duration ]]; then
186-
log_fail "ERROR: import_activity_check expected activity check \
187-
(${SECONDS}s le min_duration $min_duration)"
183+
# mmp_result: 0 (Success) check was run no activity detected
184+
# mmp_result: 121 (EREMOTEIO) check was run activity detected
185+
# mmp_result: 4 (EINTR) check was run but interrupted by user
186+
if ! echo "$RESULT" | grep -q "mmp_result: 0"; then
187+
log_note "ERROR: $RESULT"
188+
log_fail "ERROR: import_activity_check expected activity check"
188189
fi
189190

190191
return $rc

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
# with one hostid be importable by a host with a different hostid.
2525
#
2626
# STRATEGY:
27-
# 1. Simulate an active pool on another host with ztest.
27+
# 1. Simulate an active pool on another host with zhack.
2828
# 2. Verify 'zpool import' reports an active pool.
2929
# 3. Verify 'zpool import [-f] $MMP_POOL' cannot import the pool.
30-
# 4. Kill ztest to make pool eligible for import.
30+
# 4. Kill zhack to make pool eligible for import.
3131
# 5. Verify 'zpool import' fails with the expected error message.
3232
# 6. Verify 'zpool import $MMP_POOL' fails with the expected message.
3333
# 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
@@ -44,32 +44,35 @@ function cleanup
4444
{
4545
mmp_pool_destroy $MMP_POOL $MMP_DIR
4646
log_must mmp_clear_hostid
47-
ZTESTPID=$(pgrep ztest)
48-
if [ -n "$ZTESTPID" ]; then
49-
for pid in $ZTESTPID; do
47+
ZHACKPID=$(pgrep zhack)
48+
if [ -n "$ZHACKPID" ]; then
49+
for pid in $ZHACKPID; do
5050
log_must kill -9 $pid
5151
done
5252
else
53-
# if ztest not running and log present, ztest crashed
54-
if [ -f $MMP_ZTEST_LOG ]; then
55-
log_note "ztest appears to have crashed. Tail of log:"
56-
tail -n 50 $MMP_ZTEST_LOG
53+
# if zhack is not running and log present, zhack crashed
54+
if [ -f $MMP_ZHACK_LOG ]; then
55+
log_note "zhack appears to have crashed. Tail of log:"
56+
tail -n 50 $MMP_ZHACK_LOG
5757
fi
5858
fi
5959
}
6060

6161
log_assert "multihost=on|off active pool activity checks"
6262
log_onexit cleanup
6363

64-
# 1. Simulate an active pool on another host with ztest.
64+
# 1. Simulate an active pool on another host with zhack.
65+
log_note "Simulate an active pool on another host with zhack"
6566
mmp_pool_destroy $MMP_POOL $MMP_DIR
66-
mmp_pool_create $MMP_POOL $MMP_DIR
67+
mmp_pool_create_zhack $MMP_POOL $MMP_DIR
6768

6869
# 2. Verify 'zpool import' reports an active pool.
70+
log_note "Verify 'zpool import' reports an active pool"
6971
log_must mmp_set_hostid $HOSTID2
7072
log_must is_pool_imported $MMP_POOL "-d $MMP_DIR"
7173

7274
# 3. Verify 'zpool import [-f] $MMP_POOL' cannot import the pool.
75+
log_note "Verify 'zpool import [-f] $MMP_POOL' cannot import the pool"
7376
MMP_IMPORTED_MSG="Cannot import '$MMP_POOL': pool is imported"
7477

7578
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
@@ -84,21 +87,23 @@ for i in {1..10}; do
8487
"$MMP_IMPORTED_MSG"
8588
done
8689

87-
# 4. Kill ztest to make pool eligible for import. Poll with 'zpool status'.
88-
ZTESTPID=$(pgrep ztest)
89-
if [ -n "$ZTESTPID" ]; then
90-
log_must kill -9 $ZTESTPID
90+
# 4. Kill zhack to make pool eligible for import. Poll with 'zpool status'.
91+
log_note "Kill zhack to make pool eligible for import. Poll with 'zpool status'"
92+
ZHACKPID=$(pgrep zhack)
93+
if [ -n "$ZHACKPID" ]; then
94+
log_must kill -9 $ZHACKPID
9195
fi
9296
log_must wait_pool_imported $MMP_POOL "-d $MMP_DIR"
93-
if [ -f $MMP_ZTEST_LOG ]; then
94-
log_must rm $MMP_ZTEST_LOG
97+
if [ -f $MMP_ZHACK_LOG ]; then
98+
log_must rm $MMP_ZHACK_LOG
9599
fi
96100

97101
# 5. Verify 'zpool import' fails with the expected error message, when
98102
# - hostid=0: - configuration error
99103
# - hostid=matches - safe to import the pool
100104
# - hostid=different - previously imported on a different system
101105
#
106+
log_note "Verify 'zpool import' fails with the expected error message"
102107
log_must mmp_clear_hostid
103108
MMP_IMPORTED_MSG="Set a unique system hostid"
104109
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "action" "$MMP_IMPORTED_MSG"
@@ -113,13 +118,16 @@ MMP_IMPORTED_MSG="The pool was last accessed by another system."
113118
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "status" "$MMP_IMPORTED_MSG"
114119

115120
# 6. Verify 'zpool import $MMP_POOL' fails with the expected message.
121+
log_note "Verify 'zpool import $MMP_POOL' fails with the expected message"
116122
MMP_IMPORTED_MSG="pool was previously in use from another system."
117123
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
118124

119125
# 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
126+
log_note "Verify 'zpool import -f $MMP_POOL' can now import the pool"
120127
log_must import_activity_check $MMP_POOL "-f -d $MMP_DIR"
121128

122129
# 8 Verify pool may be exported/imported without -f argument.
130+
log_note "Verify pool may be exported/imported without -f argument"
123131
log_must zpool export $MMP_POOL
124132
log_must import_no_activity_check $MMP_POOL "-d $MMP_DIR"
125133

0 commit comments

Comments
 (0)