send-cpL_varied_recsize.ksh revision 5602294fda888d923d57a78bafdaf48ae6223dea
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
#
#
# Copyright (c) 2015 by Delphix. All rights reserved.
#
#
# Description:
# Verify compressed send works correctly with datasets of varying recsize.
#
# Strategy:
# 1. Check the recv behavior (into pools with features enabled and disabled)
# of all combinations of -c -p and -L. Verify the stream is compressed,
# and that the recsize property and that of a received file is correct
# according to this matrix:
#
# +---------+--------+------------+------------+-----------+-----------+
# | send | send | received | received | received | received |
# | stream | stream | file bs | prop | file bs | props |
# | recsize | flags | (disabled) | (disabled) | (enabled) | (enabled) |
# +---------+--------+------------+------------+-----------+-----------+
# | 128k | | 128k | 128k | 128k | 128k |
# | 128k | -c | Fails | Fails | 128k | 128k |
# | 128k | -p | 128k | 128k | 128k | 128k |
# | 128k | -L | 128k | 128k | 128k | 128k |
# | 128k | -cp | Fails | Fails | 128k | 128k |
# | 128k | -cL | Fails | Fails | 128k | 128k |
# | 128k | -pL | 128k | 128k | 128k | 128k |
# | 128k | -cpL | Fails | Fails | 128k | 128k |
# | 1m | | Fails | Fails | 128k | 128k |
# | 1m | -c | Fails | Fails | 128k | 128k |
# | 1m | -p | 128k | 128k | 128k | 1m |
# | 1m | -L | Fails | Fails | 1m | 128k |
# | 1m | -cp | Fails | Fails | 128k | 1m |
# | 1m | -cL | Fails | Fails | 1m | 128k |
# | 1m | -pL | Fails | Fails | 1m | 1m |
# | 1m | -cpL | Fails | Fails | 1m | 1m |
# +---------+--------+------------+------------+-----------+-----------+
#
verify_runnable "both"
function cleanup
{
}
# For a received stream, verify the recsize (prop and file) match expectations.
function check_recsize
{
typeset recv_ds=$1
typeset expected_file_bs=$2
typeset expected_recsize=$3
typeset read_recsize=$(get_prop recsize $recv_ds)
typeset read_file_bs=$(stat $file | sed -n \
's/.*IO Block: \([0-9]*\).*/\1/p')
[[ $read_recsize = $expected_recsize ]] || log_fail \
"read_recsize: $read_recsize expected_recsize: $expected_recsize"
[[ $read_file_bs = $expected_file_bs ]] || log_fail \
"read_file_bs: $read_file_bs expected_file_bs: $expected_file_bs"
}
#
# This function does a zfs send and receive according to the parameters
# below, and verifies the data shown in the strategy section.
#
# -[cpL] flags to pass through to 'zfs send'
# -d Receive into a pool with all features disabled
#
# $1 The recordsize of the send dataset
# $2 Whether or not the recv should work.
# $3 The blocksize expected in a received file (default 128k)
# $4 The recordsize property expected in a received dataset (default 128k)
#
function check
{
typeset flags='-'
c)
flags+='c'
;;
d)
;;
p)
flags+='p'
;;
L)
flags+='L'
;;
esac
done
[[ ${#flags} -eq 1 ]] && flags=''
typeset recsize=$1
typeset verify=$2
typeset expected_file_bs=${3-131072}
typeset expected_recsize=${4-131072}
typeset recv_ds=$recv_pool/$recsize
typeset stream=$BACKDIR/stream.out
datasetexists $send_ds || log_fail "send ds: $send_ds doesn't exist"
log_must eval "zfs send $flags $send_snap >$stream"
typeset stream_size=$(cat $stream | zstreamdump | sed -n \
's/ Total write size = \(.*\) (0x.*)/\1/p')
#
# Special case: For a send dataset with large blocks, don't try to
# verify the stream size is correct if the compress flag is present
# but the large blocks flag isn't. In these cases, the user data
# isn't compressed in the stream (though metadata is) so the
# verification would fail.
#
typeset do_size_test=true
do_size_test=false
datasetnonexists $recv_ds || log_fail "$recv_ds shouldn't exist"
return
fi
}
log_assert "Verify compressed send works with datasets of varying recsize."
# Create POOL3 with features disabled and datasets to create test send streams
done
# Run tests for send streams without large blocks
done
done
# Run tests for send streams with large blocks
done
done
log_pass "Compressed send works with datasets of varying recsize."