PageRenderTime 27ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_missing_005_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 124 lines | 57 code | 12 blank | 55 comment | 1 complexity | 65807d417453654471d1ecbe50bf2d50 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 2016 Spectra Logic All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. . $STF_SUITE/include/libtest.kshlib
  28. #################################################################################
  29. #
  30. # __stc_assertion_start
  31. #
  32. # ID: zpool_import_missing_005_pos
  33. #
  34. # DESCRIPTION:
  35. # Verify that a pool can still be imported even if its devices' names
  36. # have changed, for all types of devices. This is a test of vdev_geom's
  37. # import_by_guid functionality.
  38. # STRATEGY:
  39. # 1. Create a supply of file-backed md devices
  40. # 2. Create a disk-backed pool with regular, cache, log, and spare vdevs
  41. # 3. Export it
  42. # 4. Cause all the md devices names to change
  43. # 5. Verify 'zpool import' can import it
  44. #
  45. # TESTABILITY: explicit
  46. #
  47. # TEST_AUTOMATION_LEVEL: automated
  48. #
  49. # CODING_STATUS: COMPLETED (2015-01-4)
  50. #
  51. # __stc_assertion_end
  52. #
  53. ################################################################################
  54. verify_runnable "global"
  55. log_assert "Verify that all types of vdevs of a disk-backed exported pool can be imported even if they have been renamed"
  56. # Create md devices so we can control their devnames
  57. # Use high devnames so we'll be unlikely to have collisions
  58. typeset -i REGULAR_U=4000
  59. typeset -i LOG_U=4001
  60. typeset -i CACHE_U=4002
  61. typeset -i SPARE_U=4003
  62. typeset -i REGULAR_ALTU=5000
  63. typeset -i LOG_ALTU=5001
  64. typeset -i CACHE_ALTU=5002
  65. typeset -i SPARE_ALTU=5003
  66. typeset REGULAR=${TMPDIR}/regular
  67. typeset LOG=${TMPDIR}/log
  68. typeset CACHE=${TMPDIR}/cache
  69. typeset SPARE=${TMPDIR}/spare
  70. function cleanup
  71. {
  72. destroy_pool $TESTPOOL
  73. $MDCONFIG -d -u $REGULAR_U 2>/dev/null
  74. $MDCONFIG -d -u $LOG_U 2>/dev/null
  75. $MDCONFIG -d -u $CACHE_U 2>/dev/null
  76. $MDCONFIG -d -u $SPARE_U 2>/dev/null
  77. $MDCONFIG -d -u $REGULAR_ALTU 2>/dev/null
  78. $MDCONFIG -d -u $LOG_ALTU 2>/dev/null
  79. $MDCONFIG -d -u $CACHE_ALTU 2>/dev/null
  80. $MDCONFIG -d -u $SPARE_ALTU 2>/dev/null
  81. $RM -f $REGULAR
  82. $RM -f $CACHE
  83. $RM -f $LOG
  84. $RM -f $SPARE
  85. }
  86. log_onexit cleanup
  87. log_must $TRUNCATE -s 64m $REGULAR
  88. log_must $TRUNCATE -s 64m $LOG
  89. log_must $TRUNCATE -s 64m $CACHE
  90. log_must $TRUNCATE -s 64m $SPARE
  91. log_must $MDCONFIG -t vnode -a -f $REGULAR -u $REGULAR_U
  92. log_must $MDCONFIG -t vnode -a -f $LOG -u $LOG_U
  93. log_must $MDCONFIG -t vnode -a -f $CACHE -u $CACHE_U
  94. log_must $MDCONFIG -t vnode -a -f $SPARE -u $SPARE_U
  95. log_must $ZPOOL create $TESTPOOL md$REGULAR_U log md$LOG_U cache md$CACHE_U spare md$SPARE_U
  96. log_must $ZPOOL export $TESTPOOL
  97. # Now destroy the md devices, then recreate them with different names
  98. log_must $MDCONFIG -d -u $REGULAR_U
  99. log_must $MDCONFIG -d -u $LOG_U
  100. log_must $MDCONFIG -d -u $CACHE_U
  101. log_must $MDCONFIG -d -u $SPARE_U
  102. log_must $MDCONFIG -t vnode -a -f $REGULAR -u $REGULAR_ALTU
  103. log_must $MDCONFIG -t vnode -a -f $LOG -u $LOG_ALTU
  104. log_must $MDCONFIG -t vnode -a -f $CACHE -u $CACHE_ALTU
  105. log_must $MDCONFIG -t vnode -a -f $SPARE -u $SPARE_ALTU
  106. log_must $ZPOOL import $TESTPOOL
  107. zpool status $TESTPOOL
  108. log_must check_state $TESTPOOL md${REGULAR_ALTU} ONLINE
  109. log_must check_state $TESTPOOL md${LOG_ALTU} ONLINE
  110. log_must check_state $TESTPOOL md${CACHE_ALTU} ONLINE
  111. log_must check_state $TESTPOOL md${SPARE_ALTU} AVAIL
  112. log_pass