ZTS: Fix send_partial_dataset.ksh

The send_partial_dataset test verifies that partial send streams
can be resumed.  This test may occasionally fail with a "token is
corrupt" error if the `mess_send_file` truncates a send stream
below the size of the DRR_BEGIN record.  Update this function to
set a minimum size to ensure there is at least an intact DDR_BEGIN
record which allows for the receiving dataset to be created.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13177
This commit is contained in:
Brian Behlendorf 2022-03-13 13:16:49 -07:00 committed by GitHub
parent ebcf12f763
commit 56a0699e5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 12 deletions

View File

@ -583,24 +583,22 @@ function churn_files
# #
function mess_send_file function mess_send_file
{ {
typeset -i minsize=2072
file=$1 file=$1
filesize=$(stat_size $file) filesize=$(stat_size $file)
if [ $filesize -lt $minsize ]; then
log_fail "Send file too small: $filesize < $minsize"
fi
offset=$(($RANDOM * $RANDOM % $filesize)) # Truncate the send stream at a random offset after the DRR_BEGIN
# record (beyond 2072 bytes), any smaller than this and the receiving
# The random offset might truncate the send stream to be # system won't have enough info to create the partial dataset at all.
# smaller than the DRR_BEGIN record. If this happens, then # We use zstream dump to verify there is an intact DRR_BEGIN record.
# the receiving system won't have enough info to create the offset=$(((($RANDOM * $RANDOM) % ($filesize - $minsize)) + $minsize))
# partial dataset at all. We use zstream dump to check for
# this and retry in this case.
nr_begins=$(head -c $offset $file | zstream dump | \ nr_begins=$(head -c $offset $file | zstream dump | \
grep DRR_BEGIN | awk '{ print $5 }') grep DRR_BEGIN | awk '{ print $5 }')
while [ "$nr_begins" -eq 0 ]; do log_must test "$nr_begins" -eq 1
offset=$(($RANDOM * $RANDOM % $filesize))
nr_begins=$(head -c $offset $file | zstream dump | \
grep DRR_BEGIN | awk '{ print $5 }')
done
if (($RANDOM % 7 <= 1)); then if (($RANDOM % 7 <= 1)); then
# #