diff options
author | tony-zfs <[email protected]> | 2020-07-23 20:44:03 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-23 17:44:03 -0700 |
commit | 02fced3067798cbc5472f180e4c6d36f4c441a77 (patch) | |
tree | ef7bcd0c11adb5a7084679e46d1d385a5fc90cec /tests | |
parent | bfafe1780a61a1be0a84273c7155708de003033e (diff) |
Add support to decode a resume token
Adding a new subcommand to zstream called token. This
now allows users to decode a resume token to retrieve the toname
field. This can be useful for tools that need this information.
The syntax works as follows zstream token <resume_token>.
Reviewed-by: Matt Ahrens <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Paul Zuchowski <[email protected]>
Signed-off-by: Tony Perkins <[email protected]>
Closes #10558
Diffstat (limited to 'tests')
-rw-r--r-- | tests/zfs-tests/tests/functional/rsend/rsend.kshlib | 16 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index b4819245e..c82b0f008 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -26,6 +26,7 @@ # # Copyright (c) 2013, 2018 by Delphix. All rights reserved. +# Copyright (c) 2020 by Datto Inc. All rights reserved. # . $STF_SUITE/include/libtest.shlib @@ -657,6 +658,21 @@ function resume_test log_must zfs recv -suv $recvfs </$streamfs/$stream_num } +function get_resume_token +{ + sendcmd=$1 + streamfs=$2 + recvfs=$3 + + log_must eval "$sendcmd > /$streamfs/1" + mess_send_file /$streamfs/1 + log_mustnot zfs recv -suv $recvfs < /$streamfs/1 2>&1 + token=$(zfs get -Hp -o value receive_resume_token $recvfs) + echo "$token" > /$streamfs/resume_token + + return 0 +} + # # Setup filesystems for the resumable send/receive tests # diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh index 52abfe7ed..b4dc00cec 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh @@ -13,6 +13,7 @@ # # Copyright (c) 2015 by Delphix. All rights reserved. +# Copyright (c) 2020 by Datto, Inc. All rights reserved. # . $STF_SUITE/tests/functional/rsend/rsend.kshlib @@ -26,6 +27,9 @@ # 1. Create a full compressed send stream # 2. Verify zstreamdump shows this stream has the relevant features # 3. Verify zstreamdump's accounting of logical and compressed size is correct +# 4. Verify the toname from a resume token +# 5. Verify it fails with corrupted resume token +# 6. Verify it fails with missing resume token # verify_runnable "both" @@ -34,8 +38,11 @@ log_assert "Verify zstreamdump correctly interprets compressed send streams." log_onexit cleanup_pool $POOL2 typeset sendfs=$POOL2/fs +typeset streamfs=$POOL2/fs2 +typeset recvfs=$POOL2/fs3 log_must zfs create -o compress=lz4 $sendfs +log_must zfs create -o compress=lz4 $streamfs typeset dir=$(get_prop mountpoint $sendfs) write_compressible $dir 16m log_must zfs snapshot $sendfs@full @@ -56,4 +63,13 @@ csize_prop=$(get_prop used $sendfs) within_percent $csize $csize_prop 90 || log_fail \ "$csize and $csize_prop differed by too much" +x=$(get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs) +resume_token=$(cat /$streamfs/resume_token) +to_name_fs=$sendfs +log_must eval "zstream token $resume_token | grep $to_name_fs" + +bad_resume_token="1-1162e8285b-100789c6360" +log_mustnot eval "zstream token $bad_resume_token 2>&1" +log_mustnot eval "zstream token 2>&1" + log_pass "zstreamdump correctly interprets compressed send streams." |