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

https://github.com/adilger/zfs · Korn Shell · 120 lines · 52 code · 15 blank · 53 comment · 9 complexity · 949cff0d91d49344fe9f9136604f5cfb MD5 · raw file

  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 inherit' can be properly received.
  33. #
  34. # STRATEGY:
  35. # 1. Inherit property for filesystem and volume
  36. # 2. Send and restore them in the target pool
  37. # 3. Verify all the datasets can be properly backup and receive
  38. #
  39. verify_runnable "both"
  40. function cleanup
  41. {
  42. log_must cleanup_pool $POOL
  43. log_must cleanup_pool $POOL2
  44. log_must setup_test_model $POOL
  45. }
  46. log_assert "Verify changes made by 'zfs inherit' can be properly received."
  47. log_onexit cleanup
  48. #
  49. # Setting all the $FS properties as local value,
  50. #
  51. for prop in $(fs_inherit_prop); do
  52. value=$(get_prop $prop $POOL/$FS)
  53. log_must zfs set $prop=$value $POOL/$FS
  54. done
  55. #
  56. # Inherit properties in sub-datasets
  57. #
  58. for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do
  59. for prop in $(fs_inherit_prop) ; do
  60. zfs inherit $prop $ds
  61. if (($? !=0 )); then
  62. log_fail "zfs inherit $prop $ds"
  63. fi
  64. done
  65. done
  66. if is_global_zone ; then
  67. for prop in $(vol_inherit_prop) ; do
  68. zfs inherit $prop $POOL/$FS/vol
  69. if (($? !=0 )); then
  70. log_fail "zfs inherit $prop $POOL/$FS/vol"
  71. fi
  72. done
  73. fi
  74. #
  75. # Verify datasets can be backup and restore correctly
  76. # Unmount $POOL/$FS to avoid two fs mount in the same mountpoint
  77. #
  78. log_must eval "zfs send -R $POOL@final > $BACKDIR/pool-R"
  79. log_must zfs unmount -f $POOL/$FS
  80. log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-R"
  81. dstds=$(get_dst_ds $POOL $POOL2)
  82. #
  83. # Define all the POOL/POOL2 datasets pair
  84. #
  85. set -A pair "$POOL" "$dstds" \
  86. "$POOL/$FS" "$dstds/$FS" \
  87. "$POOL/$FS/fs1" "$dstds/$FS/fs1" \
  88. "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \
  89. "$POOL/pclone" "$dstds/pclone" \
  90. "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone"
  91. if is_global_zone ; then
  92. typeset -i n=${#pair[@]}
  93. pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol"
  94. pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol"
  95. fi
  96. #
  97. # Verify all the sub-datasets can be properly received.
  98. #
  99. log_must cmp_ds_subs $POOL $dstds
  100. typeset -i i=0
  101. while ((i < ${#pair[@]})); do
  102. log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]}
  103. ((i += 2))
  104. done
  105. log_pass "Changes made by 'zfs inherit' can be properly received."