1*6ccda740Sloli#!/bin/ksh -p
2*6ccda740Sloli#
3*6ccda740Sloli# CDDL HEADER START
4*6ccda740Sloli#
5*6ccda740Sloli# This file and its contents are supplied under the terms of the
6*6ccda740Sloli# Common Development and Distribution License ("CDDL"), version 1.0.
7*6ccda740Sloli# You may only use this file in accordance with the terms of version
8*6ccda740Sloli# 1.0 of the CDDL.
9*6ccda740Sloli#
10*6ccda740Sloli# A full copy of the text of the CDDL should have accompanied this
11*6ccda740Sloli# source.  A copy of the CDDL is also available via the Internet at
12*6ccda740Sloli# http://www.illumos.org/license/CDDL.
13*6ccda740Sloli#
14*6ccda740Sloli# CDDL HEADER END
15*6ccda740Sloli#
16*6ccda740Sloli
17*6ccda740Sloli#
18*6ccda740Sloli# Copyright 2016, loli10K. All rights reserved.
19*6ccda740Sloli#
20*6ccda740Sloli
21*6ccda740Sloli. $STF_SUITE/include/libtest.shlib
22*6ccda740Sloli. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
23*6ccda740Sloli
24*6ccda740Sloli#
25*6ccda740Sloli# DESCRIPTION:
26*6ccda740Sloli#	Verify ZFS can receive custom properties on both filesystems and
27*6ccda740Sloli#	snapshots from full and incremental streams.
28*6ccda740Sloli#
29*6ccda740Sloli# STRATEGY:
30*6ccda740Sloli#	1. Create a filesystem.
31*6ccda740Sloli#	2. Snapshot the filesystem.
32*6ccda740Sloli#	3. Set custom properties on both the fs and snapshots.
33*6ccda740Sloli#	4. Create different send streams with the properties.
34*6ccda740Sloli#	5. Receive the send streams and verify the properties.
35*6ccda740Sloli#
36*6ccda740Sloli
37*6ccda740Sloliverify_runnable "both"
38*6ccda740Sloli
39*6ccda740Slolitypeset streamfile_full=$TEST_BASE_DIR/streamfile_full.$$
40*6ccda740Slolitypeset streamfile_incr=$TEST_BASE_DIR/streamfile_incr.$$
41*6ccda740Sloliorig=$TESTPOOL/$TESTFS1
42*6ccda740Slolidest=$TESTPOOL/$TESTFS2
43*6ccda740Slolitypeset user_prop=$(valid_user_property 8)
44*6ccda740Slolitypeset value=$(user_property_value 8)
45*6ccda740Sloli
46*6ccda740Slolifunction cleanup
47*6ccda740Sloli{
48*6ccda740Sloli	log_must rm $streamfile_full
49*6ccda740Sloli	log_must rm $streamfile_incr
50*6ccda740Sloli	log_must zfs destroy -rf $TESTPOOL/$TESTFS1
51*6ccda740Sloli	log_must zfs destroy -rf $TESTPOOL/$TESTFS2
52*6ccda740Sloli}
53*6ccda740Sloli
54*6ccda740Slolilog_assert "ZFS can receive custom properties."
55*6ccda740Slolilog_onexit cleanup
56*6ccda740Sloli
57*6ccda740Sloli#	1. Create a filesystem.
58*6ccda740Slolilog_must zfs create $orig
59*6ccda740Sloli
60*6ccda740Sloli#	2. Snapshot the filesystem.
61*6ccda740Slolilog_must zfs snapshot $orig@snap1
62*6ccda740Slolilog_must zfs snapshot $orig@snap2
63*6ccda740Slolilog_must zfs snapshot $orig@snap3
64*6ccda740Sloli
65*6ccda740Sloli#	3. Set custom properties on both the fs and snapshots.
66*6ccda740Slolilog_must eval "zfs set '$user_prop'='$value' $orig"
67*6ccda740Slolilog_must eval "zfs set '$user_prop:snap1'='$value:snap1' $orig@snap1"
68*6ccda740Slolilog_must eval "zfs set '$user_prop:snap2'='$value:snap2' $orig@snap2"
69*6ccda740Slolilog_must eval "zfs set '$user_prop:snap3'='$value:snap3' $orig@snap3"
70*6ccda740Sloli
71*6ccda740Sloli#	4. Create different send streams with the properties.
72*6ccda740Slolilog_must eval "zfs send -p $orig@snap1 > $streamfile_full"
73*6ccda740Slolilog_must eval "zfs send -p -I $orig@snap1 $orig@snap3 > $streamfile_incr"
74*6ccda740Sloli
75*6ccda740Sloli#	5. Receive the send streams and verify the properties.
76*6ccda740Slolilog_must eval "zfs recv $dest < $streamfile_full"
77*6ccda740Slolilog_must eval "check_user_prop $dest $user_prop '$value'"
78*6ccda740Slolilog_must eval "check_user_prop $dest@snap1 '$user_prop:snap1' '$value:snap1'"
79*6ccda740Slolilog_must eval "zfs recv $dest < $streamfile_incr"
80*6ccda740Slolilog_must eval "check_user_prop $dest@snap2 '$user_prop:snap2' '$value:snap2'"
81*6ccda740Slolilog_must eval "check_user_prop $dest@snap3 '$user_prop:snap3' '$value:snap3'"
82*6ccda740Sloli
83*6ccda740Slolilog_pass "ZFS can receive custom properties passed."
84