1#!/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 works 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. Export pool, and verify the same things with zdb to 34# test the -e option. 35# 8. Import pool and discard checkpoint 36# 9. Verify zdb does not find the checkpoint anymore in the 37# current state. 38# 10.Verify that zdb cannot find the checkpointed state 39# anymore when trying to open it for verification. 40# 41 42verify_runnable "global" 43 44# 45# zdb does this thing where it imports the checkpointed state of the 46# pool under a new pool with a different name, alongside the pool 47# with the current state. The name of this temporary pool is the 48# name of the actual pool with the suffix below appended to it. 49# 50BOGUS_SUFFIX="_CHECKPOINTED_UNIVERSE" 51CHECKPOINTED_FS1=$TESTPOOL$BOGUS_SUFFIX/$TESTFS1 52 53setup_test_pool 54log_onexit cleanup_test_pool 55 56populate_test_pool 57log_must zpool checkpoint $TESTPOOL 58 59test_change_state_after_checkpoint 60 61log_must eval "zdb $TESTPOOL | grep -q \"Checkpointed uberblock found\"" 62log_mustnot eval "zdb -k $TESTPOOL | grep -q \"Checkpointed uberblock found\"" 63log_mustnot eval "zdb $TESTPOOL | grep \"Dataset $FS1\"" 64log_must eval "zdb -k $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" 65 66log_must zpool export $TESTPOOL 67 68log_must eval "zdb -e $TESTPOOL | grep \"Checkpointed uberblock found\"" 69log_mustnot eval "zdb -k -e $TESTPOOL | grep \"Checkpointed uberblock found\"" 70log_mustnot eval "zdb -e $TESTPOOL | grep \"Dataset $FS1\"" 71log_must eval "zdb -k -e $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" 72 73log_must zpool import $TESTPOOL 74 75log_must zpool checkpoint -d $TESTPOOL 76 77log_mustnot eval "zdb $TESTPOOL | grep \"Checkpointed uberblock found\"" 78log_mustnot eval "zdb -k $TESTPOOL" 79 80log_pass "zdb can analyze checkpointed pools." 81