PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/rsend/rsend_008_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 131 lines | 60 code | 21 blank | 50 comment | 10 complexity | 27c0e4aef80f724c7ea98c97d45a2249 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 2009 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/tests/functional/rsend/rsend.kshlib
  30. #
  31. # DESCRIPTION:
  32. # Changes made by 'zfs promote' can be properly received.
  33. #
  34. # STRATEGY:
  35. # 1. Separately promote pool clone, filesystem clone and volume clone.
  36. # 2. Recursively backup all the POOL and restore in POOL2
  37. # 3. Verify all the datasets and properties were properly received.
  38. #
  39. verify_runnable "both"
  40. # See issue: https://github.com/zfsonlinux/zfs/issues/6066
  41. log_unsupported "Occasionally hangs"
  42. # Origin Clone
  43. #
  44. set -A dtst "$POOL" "$POOL/pclone" \
  45. "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone"
  46. if is_global_zone ; then
  47. typeset -i n=${#dtst[@]}
  48. dtst[((n))]="$POOL/$FS/vol"; dtst[((n+1))]="$POOL/$FS/vclone"
  49. fi
  50. function cleanup
  51. {
  52. typeset origin
  53. typeset -i i=0
  54. while ((i < ${#dtst[@]})); do
  55. origin=$(get_prop origin ${dtst[$i]})
  56. if [[ $origin != "-" ]]; then
  57. log_must zfs promote ${dtst[$i]}
  58. fi
  59. ((i += 2))
  60. done
  61. origin=$(get_prop origin $POOL2)
  62. if [[ $origin != "-" ]]; then
  63. log_must zfs promote $POOL2
  64. fi
  65. log_must cleanup_pool $POOL2
  66. }
  67. log_assert "Changes made by 'zfs promote' can be properly received."
  68. log_onexit cleanup
  69. typeset -i i=0
  70. while ((i < ${#dtst[@]})); do
  71. log_must zfs promote ${dtst[((i+1))]}
  72. ((i += 2))
  73. done
  74. #
  75. # Verify zfs send -R should succeed
  76. #
  77. log_must eval "zfs send -R $POOL@final > $BACKDIR/pool-final-R"
  78. log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-final-R"
  79. dstds=$(get_dst_ds $POOL $POOL2)
  80. #
  81. # Define all the POOL/POOL2 datasets pair
  82. #
  83. set -A pair "$POOL" "$dstds" \
  84. "$POOL/$FS" "$dstds/$FS" \
  85. "$POOL/$FS/fs1" "$dstds/$FS/fs1" \
  86. "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \
  87. "$POOL/pclone" "$dstds/pclone" \
  88. "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone"
  89. if is_global_zone ; then
  90. typeset -i n=${#pair[@]}
  91. pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol"
  92. pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol"
  93. fi
  94. #
  95. # Verify all the sub-datasets can be properly received.
  96. #
  97. log_must cmp_ds_subs $POOL $dstds
  98. typeset -i i=0
  99. while ((i < ${#pair[@]})); do
  100. log_must cmp_ds_cont ${pair[$i]} ${pair[((i+1))]}
  101. log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]}
  102. ((i += 2))
  103. done
  104. # Verify the original filesystem can be promoted
  105. log_must zfs promote $dstds
  106. if is_global_zone ; then
  107. log_must zfs promote $dstds/$FS/vol
  108. fi
  109. log_must zfs promote $dstds/$FS/fs1/fs2
  110. log_pass "Changes made by 'zfs promote' can be properly received."