PageRenderTime 69ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/rsend/rsend_008_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 142 lines | 59 code | 20 blank | 63 comment | 10 complexity | 03872e777a3575a8a36f76d5652d776d MD5 | raw file
  1. #!/usr/local/bin/ksh93 -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. # $FreeBSD$
  23. #
  24. # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)rsend_008_pos.ksh 1.2 09/01/12 SMI"
  28. #
  29. . $STF_SUITE/tests/rsend/rsend.kshlib
  30. #################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: rsend_008_pos
  35. #
  36. # DESCRIPTION:
  37. # Changes made by 'zfs promote' can be properly received.
  38. #
  39. # STRATEGY:
  40. # 1. Separately promote pool clone, filesystem clone and volume clone.
  41. # 2. Recursively backup all the POOL and restore in POOL2
  42. # 3. Verify all the datesets and property be properly received.
  43. #
  44. # TESTABILITY: explicit
  45. #
  46. # TEST_AUTOMATION_LEVEL: automated
  47. #
  48. # CODING_STATUS: COMPLETED (2007-08-27)
  49. #
  50. # __stc_assertion_end
  51. #
  52. ################################################################################
  53. verify_runnable "both"
  54. # Origin Clone
  55. #
  56. set -A dtst "$POOL" "$POOL/pclone" \
  57. "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone"
  58. if is_global_zone ; then
  59. typeset -i n=${#dtst[@]}
  60. dtst[((n))]="$POOL/$FS/vol"; dtst[((n+1))]="$POOL/$FS/vclone"
  61. fi
  62. function cleanup
  63. {
  64. typeset origin
  65. typeset -i i=0
  66. while ((i < ${#dtst[@]})); do
  67. origin=$(get_prop origin ${dtst[$i]})
  68. if [[ $origin != "-" ]]; then
  69. log_must $ZFS promote ${dtst[$i]}
  70. fi
  71. ((i += 2))
  72. done
  73. origin=$(get_prop origin $POOL2)
  74. if [[ $origin != "-" ]]; then
  75. log_must $ZFS promote $POOL2
  76. fi
  77. log_must cleanup_pool $POOL2
  78. }
  79. log_assert "Changes made by 'zfs promote' can be properly received."
  80. log_onexit cleanup
  81. typeset -i i=0
  82. while ((i < ${#dtst[@]})); do
  83. log_must $ZFS promote ${dtst[((i+1))]}
  84. ((i += 2))
  85. done
  86. #
  87. # Verify zfs send -R should succeed
  88. #
  89. log_must eval "$ZFS send -R $POOL@final > $BACKDIR/pool-final-R"
  90. log_must eval "$ZFS receive -d -F $POOL2 < $BACKDIR/pool-final-R"
  91. dstds=$(get_dst_ds $POOL $POOL2)
  92. #
  93. # Define all the POOL/POOL2 datasets pair
  94. #
  95. set -A pair "$POOL" "$dstds" \
  96. "$POOL/$FS" "$dstds/$FS" \
  97. "$POOL/$FS/fs1" "$dstds/$FS/fs1" \
  98. "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \
  99. "$POOL/pclone" "$dstds/pclone" \
  100. "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone"
  101. if is_global_zone ; then
  102. typeset -i n=${#pair[@]}
  103. pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol"
  104. pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol"
  105. fi
  106. #
  107. # Verify all the sub-datasets can be properly received.
  108. #
  109. log_must cmp_ds_subs $POOL $dstds
  110. typeset -i i=0
  111. while ((i < ${#pair[@]})); do
  112. log_must cmp_ds_cont ${pair[$i]} ${pair[((i+1))]}
  113. log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]}
  114. ((i += 2))
  115. done
  116. # Verify the original filesystem can be promoted
  117. log_must $ZFS promote $dstds
  118. if is_global_zone ; then
  119. log_must $ZFS promote $dstds/$FS/vol
  120. fi
  121. log_must $ZFS promote $dstds/$FS/fs1/fs2
  122. log_pass "Changes made by 'zfs promote' can be properly received."