xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh (revision 1edba515a3484e0f74b638b203d462b3112ac84d)
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9#
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14# CDDL HEADER END
15#
16
17#
18# Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
19# Copyright 2019 Joyent, Inc.
20#
21
22# DESCRIPTION:
23#	Ensure that the MMP thread is writing uberblocks.
24#
25# STRATEGY:
26#	1. Set zfs_txg_timeout to large value
27#	2. Create a zpool
28#	3. Find the current "best" uberblock
29#	4. Sleep for enough time for a potential uberblock update
30#	5. Find the current "best" uberblock
31#	6. If the uberblock never changed, fail
32#
33
34. $STF_SUITE/include/libtest.shlib
35. $STF_SUITE/tests/functional/mmp/mmp.cfg
36. $STF_SUITE/tests/functional/mmp/mmp.kshlib
37
38verify_runnable "both"
39
40function cleanup
41{
42	default_cleanup_noexit
43	log_must set_tunable32 zfs_txg_timeout $TXG_TIMEOUT_DEFAULT
44	log_must rm -f $PREV_UBER $CURR_UBER
45	log_must mmp_clear_hostid
46}
47
48log_assert "mmp thread writes uberblocks (MMP)"
49log_onexit cleanup
50
51log_must set_tunable32 zfs_txg_timeout $TXG_TIMEOUT_LONG
52log_must mmp_set_hostid $HOSTID1
53
54default_setup_noexit $DISK
55log_must zpool set multihost=on $TESTPOOL
56
57log_must zdb -u $TESTPOOL > $PREV_UBER
58log_must sleep 5
59log_must zdb -u $TESTPOOL > $CURR_UBER
60
61if diff -u "$CURR_UBER" "$PREV_UBER"; then
62	log_fail "mmp failed to update uberblocks"
63fi
64
65log_pass "mmp thread writes uberblocks (MMP) passed"
66