xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_zdb.ksh (revision e25152834cdf3b353892835a4f3b157e066a8ed4)
1#!/bin/ksh
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright (c) 2018 Lawrence Livermore National Security, LLC.
16# Copyright (c) 2018 by Nutanix. All rights reserved.
17#
18
19. $STF_SUITE/include/libtest.shlib
20. $STF_SUITE/tests/functional/mmp/mmp.cfg
21. $STF_SUITE/tests/functional/mmp/mmp.kshlib
22
23#
24# Description:
25# zdb will work while multihost is enabled.
26#
27# Strategy:
28# 1. Create a pool
29# 2. Enable multihost
30# 3. Run zdb -d with pool and dataset arguments.
31# 4. Create a checkpoint
32# 5. Run zdb -kd with pool and dataset arguments.
33# 6. Discard the checkpoint
34# 7. Export the pool
35# 8. Run zdb -ed with pool and dataset arguments.
36#
37
38function cleanup
39{
40	datasetexists $TESTPOOL && destroy_pool $TESTPOOL
41	for DISK in $DISKS; do
42		zpool labelclear -f $DEV_RDSKDIR/$DISK
43	done
44	log_must mmp_clear_hostid
45}
46
47log_assert "Verify zdb -d works while multihost is enabled"
48log_onexit cleanup
49
50verify_runnable "global"
51verify_disk_count "$DISKS" 2
52
53default_mirror_setup_noexit $DISKS
54log_must mmp_set_hostid $HOSTID1
55log_must zpool set multihost=on $TESTPOOL
56log_must zfs snap $TESTPOOL/$TESTFS@snap
57
58log_must zdb -d $TESTPOOL
59log_must zdb -d $TESTPOOL/
60log_must zdb -d $TESTPOOL/$TESTFS
61log_must zdb -d $TESTPOOL/$TESTFS@snap
62
63log_must zpool checkpoint $TESTPOOL
64log_must zdb -kd $TESTPOOL
65log_must zdb -kd $TESTPOOL/
66log_must zdb -kd $TESTPOOL/$TESTFS
67log_must zdb -kd $TESTPOOL/$TESTFS@snap
68log_must zpool checkpoint -d $TESTPOOL
69
70log_must zpool export $TESTPOOL
71
72log_must zdb -ed $TESTPOOL
73log_must zdb -ed $TESTPOOL/
74log_must zdb -ed $TESTPOOL/$TESTFS
75log_must zdb -ed $TESTPOOL/$TESTFS@snap
76
77log_must zpool import $TESTPOOL
78
79cleanup
80
81log_pass "zdb -d works while multihost is enabled"
82