9166 zfs storage pool checkpoint
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / pool_checkpoint / checkpoint_zdb.ksh
blob4bd8d2164c8c067ebac03053fc023f10bea90313
1 #!/usr/bin/ksh -p
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.
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.
15 # Copyright (c) 2017 by Delphix. All rights reserved.
18 . $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
21 # DESCRIPTION:
22 # Ensure that checkpoint verification within zdb wowrks as
23 # we expect.
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.
40 verify_runnable "global"
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.
48 CHECKPOINT_SUFFIX="_CHECKPOINTED_UNIVERSE"
49 CHECKPOINTED_FS1=$TESTPOOL$CHECKPOINT_SUFFIX/$TESTFS1
51 setup_test_pool
52 log_onexit cleanup_test_pool
54 populate_test_pool
55 log_must zpool checkpoint $TESTPOOL
57 test_change_state_after_checkpoint
59 zdb $TESTPOOL | grep "Checkpointed uberblock found" || \
60 log_fail "zdb could not find checkpointed uberblock"
62 zdb -k $TESTPOOL | grep "Checkpointed uberblock found" && \
63 log_fail "zdb found checkpointed uberblock in checkpointed state"
65 zdb $TESTPOOL | grep "Dataset $FS1" && \
66 log_fail "zdb found destroyed dataset in current state"
68 zdb -k $TESTPOOL | grep "Dataset $CHECKPOINTED_FS1" || \
69 log_fail "zdb could not find destroyed dataset in checkpoint"
71 log_must zpool checkpoint -d $TESTPOOL
73 zdb $TESTPOOL | grep "Checkpointed uberblock found" && \
74 log_fail "zdb found checkpointed uberblock after discarding " \
75 "the checkpoint"
77 zdb -k $TESTPOOL && \
78 log_fail "zdb opened checkpointed state that was discarded"
80 log_pass "zdb can analyze checkpointed pools."