PageRenderTime 26ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_004_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 108 lines | 34 code | 14 blank | 60 comment | 1 complexity | ab1da7494b190815d97fcf709d4712ce 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 2012 Spectra Logic. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)hotspare_replace_006_pos.ksh 1.0 12/08/10 SL"
  28. #
  29. . $STF_SUITE/tests/hotspare/hotspare.kshlib
  30. . $STF_SUITE/tests/zfsd/zfsd.kshlib
  31. . $STF_SUITE/include/libgnop.kshlib
  32. ################################################################################
  33. #
  34. # __stc_assertion_start
  35. #
  36. # ID: zfs_hotspare_004_pos
  37. #
  38. # DESCRIPTION:
  39. # If a vdev gets removed from a pool with a spare, the spare will be
  40. # activated.
  41. #
  42. #
  43. # STRATEGY:
  44. # 1. Create 1 storage pools with hot spares.
  45. # 2. Remove one vdev
  46. # 3. Verify that the spare is in use.
  47. # 4. Recreate the vdev
  48. # 5. Verify that the vdev gets resilvered and the spare gets removed
  49. #
  50. # TESTABILITY: explicit
  51. #
  52. # TEST_AUTOMATION_LEVEL: automated
  53. #
  54. # CODING STATUS: COMPLETED (2012-08-10)
  55. #
  56. # __stc_assertion_end
  57. #
  58. ###############################################################################
  59. log_assert "Removing a disk from a pool results in the spare activating"
  60. function verify_assertion # spare_dev
  61. {
  62. typeset spare_dev=$1
  63. log_must destroy_gnop $REMOVAL_DISK
  64. # Check to make sure ZFS sees the disk as removed
  65. wait_for_pool_removal 20
  66. # Check that the spare was activated
  67. wait_for_pool_dev_state_change 20 $spare_dev INUSE
  68. log_must $ZPOOL status $TESTPOOL
  69. # Re-enable the missing disk
  70. log_must create_gnop $REMOVAL_DISK $PHYSPATH
  71. # Check that the disk has rejoined the pool & resilvered
  72. wait_for_pool_dev_state_change 20 $REMOVAL_NOP ONLINE
  73. wait_until_resilvered
  74. # Finally, check that the spare deactivated
  75. wait_for_pool_dev_state_change 20 $spare_dev AVAIL
  76. }
  77. typeset PHYSPATH="some_physical_path"
  78. typeset REMOVAL_DISK=$DISK0
  79. typeset REMOVAL_NOP=${DISK0}.nop
  80. typeset SPARE_DISK=$DISK4
  81. typeset SPARE_NOP=${DISK4}.nop
  82. typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}"
  83. typeset OTHER_NOPS=${OTHER_DISKS//~(E)([[:space:]]+|$)/.nop\1}
  84. set -A MY_KEYWORDS "mirror" "raidz1" "raidz2"
  85. ensure_zfsd_running
  86. log_must create_gnops $OTHER_DISKS $SPARE_DISK
  87. log_must create_gnop $REMOVAL_DISK $PHYSPATH
  88. for keyword in "${MY_KEYWORDS[@]}" ; do
  89. log_must create_pool $TESTPOOL $keyword $REMOVAL_NOP $OTHER_NOPS spare $SPARE_NOP
  90. log_must $ZPOOL set autoreplace=on $TESTPOOL
  91. iterate_over_hotspares verify_assertion $SPARE_NOP
  92. destroy_pool "$TESTPOOL"
  93. done
  94. log_pass