PageRenderTime 43ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 139 lines | 76 code | 21 blank | 42 comment | 16 complexity | 4c6e664fce94d73887270bc69055c3cc MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  1. #!/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # The contents of this file are subject to the terms of the
  6. # Common Development and Distribution License (the "License").
  7. # You may not use this file except in compliance with the License.
  8. #
  9. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10. # or http://www.opensolaris.org/os/licensing.
  11. # See the License for the specific language governing permissions
  12. # and limitations under the License.
  13. #
  14. # When distributing Covered Code, include this CDDL HEADER in each
  15. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16. # If applicable, add the following below this CDDL HEADER, with the
  17. # fields enclosed by brackets "[]" replaced with your own identifying
  18. # information: Portions Copyright [yyyy] [name of copyright owner]
  19. #
  20. # CDDL HEADER END
  21. #
  22. #
  23. # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/tests/functional/cli_root/cli_common.kshlib
  30. . $STF_SUITE/tests/functional/cli_root/zfs_send/zfs_send.cfg
  31. #
  32. # DESCRIPTION:
  33. # Verify 'zfs send' can generate valid streams with a property setup.
  34. #
  35. # STRATEGY:
  36. # 1. Setup property for filesystem
  37. # 2. Fill in some data into filesystem
  38. # 3. Create a full send streams
  39. # 4. Receive the send stream
  40. # 5. Verify the receive result
  41. #
  42. verify_runnable "both"
  43. function cleanup
  44. {
  45. snapexists $snap && \
  46. log_must zfs destroy $snap
  47. datasetexists $ctr && \
  48. log_must zfs destroy -r $ctr
  49. [[ -e $origfile ]] && \
  50. log_must rm -f $origfile
  51. [[ -e $stream ]] && \
  52. log_must rm -f $stream
  53. }
  54. function do_testing # <prop> <prop_value>
  55. {
  56. typeset property=$1
  57. typeset prop_val=$2
  58. log_must zfs set $property=$prop_val $fs
  59. file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT
  60. log_must zfs snapshot $snap
  61. zfs send $snap > $stream
  62. (( $? != 0 )) && \
  63. log_fail "'zfs send' fails to create send streams."
  64. zfs receive -d $ctr <$stream
  65. (( $? != 0 )) && \
  66. log_fail "'zfs receive' fails to receive send streams."
  67. #verify receive result
  68. ! datasetexists $rstfs && \
  69. log_fail "'zfs receive' fails to restore $rstfs"
  70. ! snapexists $rstfssnap && \
  71. log_fail "'zfs receive' fails to restore $rstfssnap"
  72. if [[ ! -e $rstfile ]] || [[ ! -e $rstsnapfile ]]; then
  73. log_fail " Data lost after receiving stream"
  74. fi
  75. compare_cksum $origfile $rstfile
  76. compare_cksum $origsnapfile $rstsnapfile
  77. #Destroy datasets and stream for next testing
  78. log_must zfs destroy $snap
  79. if is_global_zone ; then
  80. log_must zfs destroy -r $rstfs
  81. else
  82. log_must zfs destroy -r $ds_path
  83. fi
  84. log_must rm -f $stream
  85. }
  86. log_assert "Verify 'zfs send' generates valid streams with a property setup"
  87. log_onexit cleanup
  88. fs=$TESTPOOL/$TESTFS
  89. snap=$fs@$TESTSNAP
  90. ctr=$TESTPOOL/$TESTCTR
  91. if is_global_zone; then
  92. rstfs=$ctr/$TESTFS
  93. else
  94. ds_path=$ctr/${ZONE_CTR}0
  95. rstfs=$ds_path/$TESTFS
  96. fi
  97. rstfssnap=$rstfs@$TESTSNAP
  98. snapdir=".zfs/snapshot/$TESTSNAP"
  99. origfile=$TESTDIR/$TESTFILE1
  100. rstfile=/$rstfs/$TESTFILE1
  101. origsnapfile=$TESTDIR/$snapdir/$TESTFILE1
  102. rstsnapfile=/$rstfs/$snapdir/$TESTFILE1
  103. stream=$TEST_BASE_DIR/streamfile.$$
  104. set -A props "compression" "checksum" "recordsize"
  105. set -A propval "on lzjb" "on fletcher2 fletcher4 sha256" \
  106. "512 1k 4k 8k 16k 32k 64k 128k"
  107. #Create a dataset to receive the send stream
  108. log_must zfs create $ctr
  109. typeset -i i=0
  110. while (( i < ${#props[*]} ))
  111. do
  112. for value in ${propval[i]}
  113. do
  114. do_testing ${props[i]} $value
  115. done
  116. (( i = i + 1 ))
  117. done
  118. log_pass "'zfs send' generates streams with a property setup as expected."