PageRenderTime 41ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_011_neg.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 131 lines | 64 code | 19 blank | 48 comment | 5 complexity | 0bae536f74530932b09733760fc596d3 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 2008 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_create/zpool_create.shlib
  31. #
  32. # DESCRIPTION:
  33. # 'zpool create' will fail in the following cases:
  34. # existent pool; device is part of an active pool; nested virtual devices;
  35. # differently sized devices without -f option; device being currently
  36. # mounted; devices in /etc/vfstab; specified as the dedicated dump device.
  37. #
  38. # STRATEGY:
  39. # 1. Create case scenarios
  40. # 2. For each scenario, try to create a new pool with the virtual devices
  41. # 3. Verify the creation is failed.
  42. #
  43. verify_runnable "global"
  44. function cleanup
  45. {
  46. for pool in $TESTPOOL $TESTPOOL1
  47. do
  48. destroy_pool $pool
  49. done
  50. rm -rf $disk1 $disk2 $disk3
  51. if [[ -n $saved_dump_dev ]]; then
  52. log_must dumpadm -u -d $saved_dump_dev
  53. fi
  54. }
  55. log_assert "'zpool create' should be failed with inapplicable scenarios."
  56. log_onexit cleanup
  57. disk1=$(create_blockfile $FILESIZE)
  58. disk2=$(create_blockfile $FILESIZE)
  59. disk3=$(create_blockfile $FILESIZE1)
  60. mirror1="$DISK0 $DISK1"
  61. mirror2="$disk1 $disk2"
  62. raidz1=$mirror1
  63. raidz2=$mirror2
  64. diff_size_dev="$disk2 $disk3"
  65. vfstab_dev=$(find_vfstab_dev)
  66. if is_illumos; then
  67. specified_dump_dev=${DISK0}s0
  68. saved_dump_dev=$(save_dump_dev)
  69. cyl=$(get_endslice $DISK0 6)
  70. log_must set_partition 7 "$cyl" $SIZE1 $DISK0
  71. fi
  72. create_pool $TESTPOOL $DISK0
  73. #
  74. # Set up the testing scenarios parameters
  75. #
  76. set -A arg \
  77. "$TESTPOOL1 $DISK0" \
  78. "$TESTPOOL1 mirror mirror $mirror1 mirror $mirror2" \
  79. "$TESTPOOL1 raidz raidz $raidz1 raidz $raidz2" \
  80. "$TESTPOOL1 raidz1 raidz1 $raidz1 raidz1 $raidz2" \
  81. "$TESTPOOL1 mirror raidz $raidz1 raidz $raidz2" \
  82. "$TESTPOOL1 mirror raidz1 $raidz1 raidz1 $raidz2" \
  83. "$TESTPOOL1 raidz mirror $mirror1 mirror $mirror2" \
  84. "$TESTPOOL1 raidz1 mirror $mirror1 mirror $mirror2" \
  85. "$TESTPOOL1 mirror $diff_size_dev" \
  86. "$TESTPOOL1 raidz $diff_size_dev" \
  87. "$TESTPOOL1 raidz1 $diff_size_dev" \
  88. "$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \
  89. "$TESTPOOL1 $vfstab_dev" \
  90. "$TESTPOOL1 ${DISK0}s10" \
  91. "$TESTPOOL1 spare $pooldev2"
  92. unset NOINUSE_CHECK
  93. typeset -i i=0
  94. while (( i < ${#arg[*]} )); do
  95. log_mustnot zpool create ${arg[i]}
  96. (( i = i+1 ))
  97. done
  98. # now destroy the pool to be polite
  99. log_must zpool destroy -f $TESTPOOL
  100. if is_illumos; then
  101. # create/destroy a pool as a simple way to set the partitioning
  102. # back to something normal so we can use this $disk as a dump device
  103. log_must zpool create -f $TESTPOOL3 $DISK1
  104. log_must zpool destroy -f $TESTPOOL3
  105. log_must dumpadm -d ${DEV_DSKDIR}/$specified_dump_dev
  106. log_mustnot zpool create -f $TESTPOOL1 "$specified_dump_dev"
  107. # Also check to see that in-use checking prevents us from creating
  108. # a zpool from just the first slice on the disk.
  109. log_mustnot zpool create \
  110. -f $TESTPOOL1 ${specified_dump_dev}s0
  111. fi
  112. log_pass "'zpool create' is failed as expected with inapplicable scenarios."