xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh (revision 7ed546340881b42865171ddfa1a6167b289faae3)
1#!/usr/bin/ksh -p
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) 2017 by Delphix. All rights reserved.
16#
17
18. $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
19
20#
21# DESCRIPTION:
22#	Ensure that checkpoint verification within zdb wowrks as
23#	we expect.
24#
25# STRATEGY:
26#	1. Create pool
27#	2. Populate it
28#	3. Take checkpoint
29#	4. Modify data (include at least one destructive change)
30#	5. Verify zdb finds checkpoint when run on current state
31#	6. Verify zdb finds old dataset when run on checkpointed
32#	   state
33#	7. Discard checkpoint
34#	8. Verify zdb does not find the checkpoint anymore in the
35#	   current state.
36#	9. Verify that zdb cannot find the checkpointed state
37#	   anymore when trying to open it for verification.
38#
39
40verify_runnable "global"
41
42#
43# zdb does this thing where it imports the checkpointed state of the
44# pool under a new pool with a different name, alongside the pool
45# with the current state. The name of this temporary pool is the
46# name of the actual pool with the suffix below appended to it.
47#
48CHECKPOINT_SUFFIX="_CHECKPOINTED_UNIVERSE"
49CHECKPOINTED_FS1=$TESTPOOL$CHECKPOINT_SUFFIX/$TESTFS1
50
51setup_test_pool
52log_onexit cleanup_test_pool
53
54populate_test_pool
55log_must zpool checkpoint $TESTPOOL
56
57test_change_state_after_checkpoint
58
59zdb $TESTPOOL | grep "Checkpointed uberblock found" || \
60	log_fail "zdb could not find checkpointed uberblock"
61
62zdb -k $TESTPOOL | grep "Checkpointed uberblock found" && \
63	log_fail "zdb found checkpointed uberblock in checkpointed state"
64
65zdb $TESTPOOL | grep "Dataset $FS1" && \
66	log_fail "zdb found destroyed dataset in current state"
67
68zdb -k $TESTPOOL | grep "Dataset $CHECKPOINTED_FS1" || \
69	log_fail "zdb could not find destroyed dataset in checkpoint"
70
71log_must zpool checkpoint -d $TESTPOOL
72
73zdb $TESTPOOL | grep "Checkpointed uberblock found" && \
74	log_fail "zdb found checkpointed uberblock after discarding " \
75	"the checkpoint"
76
77zdb -k $TESTPOOL && \
78	log_fail "zdb opened checkpointed state that was discarded"
79
80log_pass "zdb can analyze checkpointed pools."
81