PageRenderTime 43ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/hotspare/hotspare_replace_001_neg.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 112 lines | 39 code | 18 blank | 55 comment | 7 complexity | 1794cb7afc208010c1ba08062cd33230 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 "@(#)hotspare_replace_001_neg.ksh 1.4 09/06/22 SMI"
  28. #
  29. . $STF_SUITE/tests/hotspare/hotspare.kshlib
  30. ################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: hotspare_replace_001_neg
  35. #
  36. # DESCRIPTION:
  37. # 'zpool replace <pool> <odev> <ndev>...' should return fail if
  38. # - try to replace a basic vdev that already has an activated
  39. # hot spare.
  40. # - try to replace log device.
  41. #
  42. # STRATEGY:
  43. # 1. Create a storage pool
  44. # 2. Add hot spare devices to the pool
  45. # 3. For each scenario, try to replace the basic vdev with the given hot spares
  46. # 4. Verify the the replace operation get failed
  47. #
  48. # TESTABILITY: explicit
  49. #
  50. # TEST_AUTOMATION_LEVEL: automated
  51. #
  52. # CODING STATUS: COMPLETED (2006-06-07)
  53. #
  54. # __stc_assertion_end
  55. #
  56. ###############################################################################
  57. verify_runnable "global"
  58. function cleanup
  59. {
  60. poolexists $TESTPOOL && \
  61. destroy_pool $TESTPOOL
  62. partition_cleanup
  63. }
  64. function verify_assertion # dev
  65. {
  66. typeset dev=$1
  67. for odev in ${pooldevs[@]} ; do
  68. log_must $ZPOOL replace $TESTPOOL $odev $dev
  69. log_mustnot $ZPOOL replace $TESTPOOL $odev $availdev
  70. log_must $ZPOOL detach $TESTPOOL $dev
  71. done
  72. if [[ -n ${logdevs[@]} ]] ; then
  73. for odev in ${logdevs[@]} ; do
  74. log_mustnot $ZPOOL replace $TESTPOOL $odev $dev
  75. done
  76. fi
  77. }
  78. log_assert "'zpool replace <pool> <odev> <ndev>' should fail with inapplicable scenarios."
  79. log_onexit cleanup
  80. set_devs
  81. typeset dev_nonexist
  82. typeset availdev=${devarray[2]}
  83. dev_nonexist=${disk}sbad_slice_num
  84. for keyword in "${keywords[@]}" ; do
  85. setup_hotspares "$keyword" "${sparedevs[@]} $availdev"
  86. for odev in ${pooldevs[@]} ; do
  87. for ndev in $dev_nonexist ; do
  88. log_mustnot $ZPOOL replace $TESTPOOL $odev $ndev
  89. done
  90. done
  91. iterate_over_hotspares verify_assertion
  92. destroy_pool "$TESTPOOL"
  93. done
  94. log_pass "'zpool replace <pool> <odev> <ndev>' fail with inapplicable scenarios."