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

https://github.com/adilger/zfs · Korn Shell · 152 lines · 85 code · 22 blank · 45 comment · 0 complexity · 45dde68954bf5efe6d3ef6f0c34f79ec 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 that incrementals (redacted and normal) work with redacted datasets.
  19. #
  20. # Strategy:
  21. # 1. Test normal incrementals from the original snap to a subset of the
  22. # redaction list.
  23. # 2. Test receipt of intermediate clones, and their children.
  24. # 3. Test receipt with origin snap specified by '-o origin='.
  25. # 4. Test incrementals from redaction bookmarks.
  26. #
  27. typeset ds_name="incrementals"
  28. typeset sendfs="$POOL/$ds_name"
  29. typeset recvfs="$POOL2/$ds_name"
  30. typeset clone="$POOL/${ds_name}_clone"
  31. typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
  32. typeset stream=$(mktemp $tmpdir/stream.XXXX)
  33. setup_dataset $ds_name '' setup_incrementals
  34. typeset clone_mnt="$(get_prop mountpoint $clone)"
  35. typeset send_mnt="$(get_prop mountpoint $sendfs)"
  36. typeset recv_mnt="/$POOL2/$ds_name"
  37. log_onexit redacted_cleanup $sendfs $recvfs $POOL2/rfs
  38. # Setup a redacted send using a redaction list at varying depth.
  39. log_must zfs redact $sendfs@snap0 book1 $POOL/rm@snap $POOL/stride3@snap \
  40. $POOL/stride5@snap
  41. log_must eval "zfs send --redact book1 $sendfs@snap0 >$stream"
  42. log_must eval "zfs receive $POOL2/rfs <$stream"
  43. # Verify receipt of normal incrementals to redaction list members.
  44. log_must eval "zfs send -i $sendfs@snap0 $POOL/stride3@snap >$stream"
  45. log_must eval "zfs recv $POOL2/rstride3 <$stream"
  46. log_must diff -r /$POOL/stride3 /$POOL2/rstride3
  47. log_must eval "zfs send -i $sendfs@snap0 $POOL/stride5@snap >$stream"
  48. log_must eval "zfs recv $POOL2/rstride5 <$stream"
  49. log_must diff -r /$POOL/stride5 /$POOL2/rstride5
  50. # But not a normal child that we weren't redacted with respect to.
  51. log_must eval "zfs send -i $sendfs@snap0 $POOL/hole@snap >$stream"
  52. log_mustnot eval "zfs recv $POOL2/rhole@snap <$stream"
  53. # Verify we can receive an intermediate clone redacted with respect to a
  54. # subset of the original redaction list.
  55. log_must zfs redact $POOL/int@snap book2 $POOL/rm@snap
  56. log_must eval "zfs send -i $sendfs@snap0 --redact book2 $POOL/int@snap >$stream"
  57. log_must eval "zfs recv $POOL2/rint <$stream"
  58. compare_files $POOL/int $POOL2/rint "f1" "$RANGE0"
  59. compare_files $POOL/int $POOL2/rint "f2" "$RANGE15"
  60. compare_files $POOL/int $POOL2/rint "d1/f1" "$RANGE16"
  61. log_must mount_redacted -f $POOL2/rint
  62. # Verify we can receive grandchildren on the child.
  63. log_must eval "zfs send -i $POOL/int@snap $POOL/rm@snap >$stream"
  64. log_must eval "zfs receive $POOL2/rrm <$stream"
  65. log_must diff -r /$POOL/rm /$POOL2/rrm
  66. # But not a grandchild that the received child wasn't redacted with respect to.
  67. log_must eval "zfs send -i $POOL/int@snap $POOL/write@snap >$stream"
  68. log_mustnot eval "zfs recv $POOL2/rwrite<$stream"
  69. # Verify we cannot receive an intermediate clone that isn't redacted with
  70. # respect to a subset of the original redaction list.
  71. log_must zfs redact $POOL/int@snap book4 $POOL/rm@snap $POOL/write@snap
  72. log_must eval "zfs send -i $sendfs@snap0 --redact book4 $POOL/int@snap >$stream"
  73. log_mustnot eval "zfs recv $POOL2/rint <$stream"
  74. log_must zfs redact $POOL/int@snap book5 $POOL/write@snap
  75. log_must eval "zfs send -i $sendfs@snap0 --redact book5 $POOL/int@snap >$stream"
  76. log_mustnot eval "zfs recv $POOL2/rint <$stream"
  77. log_mustnot zfs redact $POOL/int@snap book6 $POOL/hole@snap
  78. # Verify we can receive a full clone of the grandchild on the child.
  79. log_must eval "zfs send $POOL/write@snap >$stream"
  80. log_must eval "zfs recv -o origin=$POOL2/rint@snap $POOL2/rwrite <$stream"
  81. log_must diff -r /$POOL/write /$POOL2/rwrite
  82. # Along with other origins.
  83. log_must eval "zfs recv -o origin=$POOL2/rfs@snap0 $POOL2/rwrite1 <$stream"
  84. log_must diff -r /$POOL/write /$POOL2/rwrite1
  85. log_must eval "zfs recv -o origin=$POOL2@init $POOL2/rwrite2 <$stream"
  86. log_must diff -r /$POOL/write /$POOL2/rwrite2
  87. log_must zfs destroy -R $POOL2/rwrite2
  88. log_must zfs destroy -R $POOL2/rfs
  89. # Write some data for tests of incremental sends from bookmarks
  90. log_must zfs snapshot $sendfs@snap1
  91. log_must zfs clone $sendfs@snap1 $POOL/hole1
  92. typeset mntpnt=$(get_prop mountpoint $POOL/hole1)
  93. log_must dd if=/dev/zero of=$mntpnt/f2 bs=128k count=16 conv=notrunc
  94. log_must zfs snapshot $POOL/hole1@snap
  95. log_must zfs clone $sendfs@snap1 $POOL/write1
  96. mntpnt=$(get_prop mountpoint $POOL/write1)
  97. log_must dd if=/dev/urandom of=$mntpnt/f2 bs=128k count=16 conv=notrunc
  98. log_must zfs snapshot $POOL/write1@snap
  99. log_must zfs clone $POOL/int@snap $POOL/write2
  100. mntpnt=$(get_prop mountpoint $POOL/write2)
  101. log_must dd if=/dev/urandom of=$mntpnt/f2 bs=128k count=16 conv=notrunc
  102. log_must zfs snapshot $POOL/write2@snap
  103. # Setup a redacted send using a redaction list at varying depth.
  104. log_must zfs redact $sendfs@snap0 book7 $POOL/rm@snap $POOL/stride3@snap \
  105. $POOL/stride5@snap
  106. log_must eval "zfs send --redact book7 $sendfs@snap0 >$stream"
  107. log_must eval "zfs receive $POOL2/rfs <$stream"
  108. # Verify we can receive a redacted incremental sending from the bookmark.
  109. log_must zfs redact $sendfs@snap1 book8 $POOL/write1@snap
  110. log_must eval "zfs send -i $sendfs#book7 --redact book8 $sendfs@snap1 >$stream"
  111. log_must eval "zfs receive $POOL2/rfs <$stream"
  112. # The stride3 and stride5 snaps redact 3 128k blocks at block offsets 0 15 and
  113. # 30 of f2. The write1 snap only covers the first two of those three blocks.
  114. compare_files $sendfs $POOL2/rfs "f2" "$RANGE12"
  115. log_must mount_redacted -f $POOL2/rfs
  116. log_must diff $send_mnt/f1 /$POOL2/rfs/f1
  117. log_must diff $send_mnt/d1/f1 /$POOL2/rfs/d1/f1
  118. unmount_redacted $POOL2/rfs
  119. # Verify we can receive a normal child we weren't redacted with respect to by
  120. # sending from the bookmark.
  121. log_must eval "zfs send -i $sendfs#book7 $POOL/hole1@snap >$stream"
  122. log_must eval "zfs recv $POOL2/rhole1 <$stream"
  123. log_must diff -r /$POOL/hole1 /$POOL2/rhole1
  124. # Verify we can receive an intermediate clone redacted with respect to a
  125. # non-subset if we send from the bookmark.
  126. log_must zfs redact $POOL/int@snap book9 $POOL/write2@snap
  127. log_must eval "zfs send -i $sendfs#book7 --redact book9 $POOL/int@snap >$stream"
  128. log_must eval "zfs receive $POOL2/rint <$stream"
  129. compare_files $sendfs $POOL2/rint "f2" "$RANGE12"
  130. log_pass "Incrementals (redacted and normal) work with redacted datasets."