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 by Delphix. All rights reserved. 16# 17 18. $STF_SUITE/tests/functional/redacted_send/redacted.kshlib 19 20# 21# Description: 22# Verify the list of redacted snapshot guids as properties. 23# 24# Strategy: 25# 1. Create a redacted dataset and receive it into another pool. 26# 2. Verify that the redaction list in the book mark (according to zdb) 27# matches the list shown in the redact_snaps property. 28# 3. Verify that the received snapshot has a matching redaction list. 29# 30 31typeset ds_name="props" 32typeset sendfs="$POOL/$ds_name" 33typeset recvfs="$POOL2/$ds_name" 34typeset clone="$POOL/${ds_name}_clone" 35typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" 36typeset stream=$(mktemp $tmpdir/stream.XXXX) 37setup_dataset $ds_name '' 38typeset mntpnt 39 40log_onexit redacted_cleanup $sendfs $recvfs 41 42# Verify a plain dataset, snapshot or bookmark has an empty list. 43log_must zfs snapshot $sendfs@empty_snapshot 44log_must zfs bookmark $sendfs@empty_snapshot $sendfs#empty_bookmark 45found_list=$(get_prop redact_snaps $sendfs) 46[[ $found_list = "-" ]] || log_fail "Unexpected dataset list: $found_list" 47found_list=$(get_prop redact_snaps $sendfs@empty_snapshot) 48[[ $found_list = "-" ]] || log_fail "Unexpected snapshot list: $found_list" 49found_list=$(get_prop redact_snaps $sendfs#empty_bookmark) 50[[ $found_list = "-" ]] || log_fail "Unexpected bookmark list: $found_list" 51 52# Fill in a different block in every clone. 53for i in {1..16}; do 54 log_must zfs clone $sendfs@snap ${clone}$i 55 mntpnt=$(get_prop mountpoint ${clone}$i) 56 log_must dd if=/dev/urandom of=$mntpnt/f2 bs=64k count=1 seek=$i \ 57 conv=notrunc 58 log_must zfs snapshot ${clone}$i@snap 59done 60 61log_must zfs redact $sendfs@snap book1 $clone{1..16}@snap 62log_must eval "zfs send --redact book1 $sendfs@snap >$stream" 63log_must eval "zfs recv $recvfs <$stream" 64 65get_guid_list $tmpdir/prop_list $sendfs#book1 66get_guid_list $tmpdir/zdb_list $sendfs#book1 true 67get_guid_list $tmpdir/recvd_prop_list $recvfs@snap 68 69count=$(wc -l < $tmpdir/prop_list) 70[ $count -eq 16 ] || log_fail "Found incorrect number of redaction snapshots." 71 72diff $tmpdir/prop_list $tmpdir/zdb_list || \ 73 log_fail "Property list differed from zdb output" 74diff $tmpdir/prop_list $tmpdir/recvd_prop_list || \ 75 log_fail "Received property list differed from sent" 76 77log_pass "The redaction list is consistent between sent and received datasets." 78