PageRenderTime 185ms CodeModel.GetById 14ms RepoModel.GetById 2ms app.codeStats 0ms

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

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 83 lines | 34 code | 17 blank | 32 comment | 2 complexity | 5b0f8fb9bc590bbeff13d9798f62da7a 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 2017 Spectra Logic. All rights reserved.
  25. # Use is subject to license terms.
  26. . $STF_SUITE/tests/hotspare/hotspare.kshlib
  27. verify_runnable "global"
  28. function cleanup
  29. {
  30. $ZPOOL status $TESTPOOL
  31. if poolexists $TESTPOOL ; then
  32. destroy_pool $TESTPOOL
  33. fi
  34. partition_cleanup
  35. }
  36. function verify_assertion # damage_type
  37. {
  38. typeset mntp=$(get_prop mountpoint $TESTPOOL)
  39. # Write some data to the pool so the replacing vdev doesn't complete
  40. # immediately.
  41. $TIMEOUT 60s $DD if=/dev/zero of=$mntp/zerofile bs=131072
  42. log_must $ZINJECT -d $FAULT_DISK -A fault $TESTPOOL
  43. log_must check_state $TESTPOOL $FAULT_DISK FAULTED
  44. # Replace the failed device. Realistically, the new device would have
  45. # the same physical path as the failed one, but it doesn't matter for
  46. # our purposes.
  47. log_must $ZPOOL replace $TESTPOOL $FAULT_DISK $REPLACEMENT_DISK
  48. # Add the spare, and check that it does not activate
  49. log_must $ZPOOL add $TESTPOOL spare $SDEV
  50. # Wait a few seconds before verifying the state
  51. $SLEEP 10
  52. log_must check_state $TESTPOOL "$SDEV" "AVAIL"
  53. }
  54. log_onexit cleanup
  55. log_assert "zfsd will not use newly added spares on replacing vdevs"
  56. ensure_zfsd_running
  57. typeset FAULT_DISK=$DISK0
  58. typeset REPLACEMENT_DISK=$DISK2
  59. typeset SDEV=$DISK3
  60. typeset POOLDEVS="$DISK0 $DISK1"
  61. set -A MY_KEYWORDS "mirror"
  62. for keyword in "${MY_KEYWORDS[@]}" ; do
  63. log_must create_pool $TESTPOOL $keyword $POOLDEVS
  64. verify_assertion
  65. destroy_pool "$TESTPOOL"
  66. done