diff options
author | Brian Behlendorf <[email protected]> | 2022-03-13 13:16:49 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-03-13 13:16:49 -0700 |
commit | 56a0699e5e06242a7a134ad080aadfa13486bb59 (patch) | |
tree | e973cbe43bca0a5a3b088123c2998a684a09092e /tests | |
parent | ebcf12f763130d17daeac7f0065adc924eff3847 (diff) |
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 <[email protected]>
Reviewed-by: Rich Ercolani <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #13177
Diffstat (limited to 'tests')
-rw-r--r-- | tests/zfs-tests/tests/functional/rsend/rsend.kshlib | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 2c8085f22..8d704ee36 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -583,24 +583,22 @@ function churn_files # function mess_send_file { + typeset -i minsize=2072 file=$1 filesize=$(stat_size $file) + if [ $filesize -lt $minsize ]; then + log_fail "Send file too small: $filesize < $minsize" + fi - offset=$(($RANDOM * $RANDOM % $filesize)) - - # The random offset might truncate the send stream to be - # smaller than the DRR_BEGIN record. If this happens, then - # the receiving system won't have enough info to create the - # partial dataset at all. We use zstream dump to check for - # this and retry in this case. + # Truncate the send stream at a random offset after the DRR_BEGIN + # record (beyond 2072 bytes), any smaller than this and the receiving + # system won't have enough info to create the partial dataset at all. + # We use zstream dump to verify there is an intact DRR_BEGIN record. + offset=$(((($RANDOM * $RANDOM) % ($filesize - $minsize)) + $minsize)) nr_begins=$(head -c $offset $file | zstream dump | \ grep DRR_BEGIN | awk '{ print $5 }') - while [ "$nr_begins" -eq 0 ]; do - offset=$(($RANDOM * $RANDOM % $filesize)) - nr_begins=$(head -c $offset $file | zstream dump | \ - grep DRR_BEGIN | awk '{ print $5 }') - done + log_must test "$nr_begins" -eq 1 if (($RANDOM % 7 <= 1)); then # |