/tests/zfs-tests/tests/functional/redacted_send/redacted_many_clones.ksh

https://github.com/adilger/zfs · Korn Shell · 68 lines · 29 code · 10 blank · 29 comment · 1 complexity · 0760aef884921593291424e55e8dde31 MD5 · raw file

  1. #!/bin/ksh
  2. #
  3. # This file and its contents are supplied under the terms of the
  4. # Common Development and Distribution License ("CDDL"), version 1.0.
  5. # You may only use this file in accordance with the terms of version
  6. # 1.0 of the CDDL.
  7. #
  8. # A full copy of the text of the CDDL should have accompanied this
  9. # source. A copy of the CDDL is also available via the Internet at
  10. # http://www.illumos.org/license/CDDL.
  11. #
  12. #
  13. # Copyright (c) 2018 by Delphix. All rights reserved.
  14. #
  15. . $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
  16. #
  17. # Description:
  18. # Verify redacted send can deal with a large redaction list.
  19. #
  20. # Strategy:
  21. # 1. Create 64 clones of sendfs each of which modifies two blocks in a file.
  22. # The first modification is at an offset unique to each clone, and the
  23. # second (the last block in the file) is common to them all.
  24. # 2. Verify a redacted stream with a reasonable redaction list length can
  25. # be correctly processed.
  26. # 3. Verify that if the list is too long, the send fails gracefully.
  27. #
  28. typeset ds_name="many_clones"
  29. typeset sendfs="$POOL/$ds_name"
  30. typeset recvfs="$POOL2/$ds_name"
  31. typeset clone="$POOL/${ds_name}_clone"
  32. typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
  33. typeset stream=$(mktemp $tmpdir/stream.XXXX)
  34. setup_dataset $ds_name ''
  35. typeset clone_mnt="$(get_prop mountpoint $clone)"
  36. typeset send_mnt="$(get_prop mountpoint $sendfs)"
  37. typeset recv_mnt="/$POOL2/$ds_name"
  38. typeset redaction_list=''
  39. typeset mntpnt
  40. log_onexit redacted_cleanup $sendfs $recvfs
  41. # Fill in both the last block, and a different block in every clone.
  42. for i in {1..64}; do
  43. log_must zfs clone $sendfs@snap ${clone}$i
  44. mntpnt=$(get_prop mountpoint ${clone}$i)
  45. log_must dd if=/dev/urandom of=$mntpnt/f2 bs=64k count=1 seek=$i \
  46. conv=notrunc
  47. log_must dd if=/dev/urandom of=$mntpnt/f2 bs=64k count=1 seek=63 \
  48. conv=notrunc
  49. log_must zfs snapshot ${clone}$i@snap
  50. done
  51. # The limit isn't necessarily 32 snapshots. The maximum number of snapshots in
  52. # the redacted list is determined in dsl_bookmark_create_redacted_check().
  53. log_must zfs redact $sendfs@snap book1 $clone{1..32}@snap
  54. log_must eval "zfs send --redact book1 $sendfs@snap >$stream"
  55. log_must eval "zfs recv $recvfs <$stream"
  56. compare_files $sendfs $recvfs "f2" "$RANGE8"
  57. log_mustnot zfs redact $sendfs@snap book2 $clone{1..64}@snap
  58. log_pass "Redacted send can deal with a large redaction list."