1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright 2016, loli10K. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib 23 24# 25# DESCRIPTION: 26# Verify ZFS successfully receive and restore properties. 27# 28# STRATEGY: 29# 1. Create a filesystem. 30# 2. Create a full stream with properties and receive it. 31# 3. Create also an incremental stream without some properties and a truncated 32# stream. 33# 4. Fail to receive the truncated incremental stream and verify previously 34# received properties are still present. 35# 5. Receive the complete incremental send stream and verify that sent 36# properties are successfully received. 37# 38 39verify_runnable "both" 40 41orig=$TESTPOOL/$TESTFS1 42dest=$TESTPOOL/$TESTFS2 43typeset userprop=$(valid_user_property 8) 44typeset userval=$(user_property_value 8) 45typeset streamfile_full=$TESTDIR/streamfile_full.$$ 46typeset streamfile_incr=$TESTDIR/streamfile_incr.$$ 47typeset streamfile_trun=$TESTDIR/streamfile_trun.$$ 48 49function cleanup 50{ 51 log_must rm $streamfile_full 52 log_must rm $streamfile_incr 53 log_must rm $streamfile_trun 54 log_must zfs destroy -rf $orig 55 log_must zfs destroy -rf $dest 56} 57 58log_assert "ZFS successfully receive and restore properties." 59log_onexit cleanup 60 61# 1. Create a filesystem. 62log_must eval "zfs create $orig" 63mntpnt=$(get_prop mountpoint $orig) 64 65# 2. Create a full stream with properties and receive it. 66log_must eval "zfs set compression='gzip-1' $orig" 67log_must eval "zfs set '$userprop'='$userval' $orig" 68log_must eval "zfs snapshot $orig@snap1" 69log_must eval "zfs send -p $orig@snap1 > $streamfile_full" 70log_must eval "zfs recv $dest < $streamfile_full" 71log_must eval "check_prop_source $dest compression 'gzip-1' received" 72log_must eval "check_prop_source $dest '$userprop' '$userval' received" 73 74# 3. Create also an incremental stream without some properties and a truncated 75# stream. 76log_must eval "zfs set compression='gzip-2' $orig" 77log_must eval "zfs inherit '$userprop' $orig" 78log_must eval "dd if=/dev/urandom of=$mntpnt/file bs=1024k count=10" 79log_must eval "zfs snapshot $orig@snap2" 80log_must eval "zfs send -p -i $orig@snap1 $orig@snap2 > $streamfile_incr" 81log_must eval "dd if=$streamfile_incr of=$streamfile_trun bs=1024k count=9" 82log_must eval "zfs snapshot $orig@snap3" 83log_must eval "zfs send -p -i $orig@snap1 $orig@snap3 > $streamfile_incr" 84 85# 4. Fail to receive the truncated incremental stream and verify previously 86# received properties are still present. 87log_mustnot eval "zfs recv -F $dest < $streamfile_trun" 88log_must eval "check_prop_source $dest compression 'gzip-1' received" 89log_must eval "check_prop_source $dest '$userprop' '$userval' received" 90 91# 5. Receive the complete incremental send stream and verify that sent 92# properties are successfully received. 93log_must eval "zfs recv -F $dest < $streamfile_incr" 94log_must eval "check_prop_source $dest compression 'gzip-2' received" 95log_must eval "check_prop_source $dest '$userprop' '-' '-'" 96 97log_pass "ZFS properties are successfully received and restored." 98