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

/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_010_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 92 lines | 35 code | 17 blank | 40 comment | 3 complexity | a8735822e2beafbeb98058ab28902bff MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  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 2007 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. . $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
  31. #
  32. # DESCRIPTION:
  33. # 'zpool -D -a' can import all the specified directories destroyed pools.
  34. #
  35. # STRATEGY:
  36. # 1. Create a 5 ways mirror pool A with dev0/1/2/3/4, then destroy it.
  37. # 2. Create a stripe pool B with dev1. Then destroy it.
  38. # 3. Create a raidz2 pool C with dev2/3/4. Then destroy it.
  39. # 4. Create a raidz pool D with dev3/4. Then destroy it.
  40. # 5. Create a stripe pool E with dev4. Then destroy it.
  41. # 6. Verify 'zpool import -D -a' recover all the pools.
  42. #
  43. verify_runnable "global"
  44. function cleanup
  45. {
  46. typeset dt
  47. for dt in $poolE $poolD $poolC $poolB $poolA; do
  48. destroy_pool $dt
  49. done
  50. log_must rm -rf $DEVICE_DIR/*
  51. typeset i=0
  52. while (( i < $MAX_NUM )); do
  53. log_must mkfile $FILE_SIZE ${DEVICE_DIR}/${DEVICE_FILE}$i
  54. ((i += 1))
  55. done
  56. }
  57. log_assert "'zpool -D -a' can import all the specified directories " \
  58. "destroyed pools."
  59. log_onexit cleanup
  60. poolA=poolA.$$; poolB=poolB.$$; poolC=poolC.$$; poolD=poolD.$$; poolE=poolE.$$
  61. log_must zpool create $poolA mirror $VDEV0 $VDEV1 $VDEV2 $VDEV3 $VDEV4
  62. log_must zpool destroy $poolA
  63. log_must zpool create $poolB $VDEV1
  64. log_must zpool destroy $poolB
  65. log_must zpool create $poolC raidz2 $VDEV2 $VDEV3 $VDEV4
  66. log_must zpool destroy $poolC
  67. log_must zpool create $poolD raidz $VDEV3 $VDEV4
  68. log_must zpool destroy $poolD
  69. log_must zpool create $poolE $VDEV4
  70. log_must zpool destroy $poolE
  71. log_must zpool import -d $DEVICE_DIR -D -f -a
  72. for dt in $poolA $poolB $poolC $poolD $poolE; do
  73. log_must datasetexists $dt
  74. done
  75. log_pass "'zpool -D -a' test passed."