]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
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 | # | |
24 | # Copyright 2009 Sun Microsystems, Inc. All rights reserved. | |
25 | # Use is subject to license terms. | |
26 | # | |
27 | ||
28 | # | |
c1d9abf9 | 29 | # Copyright (c) 2013, 2016 by Delphix. All rights reserved. |
6bb24f4d BB |
30 | # |
31 | ||
32 | . $STF_SUITE/include/libtest.shlib | |
33 | . $STF_SUITE/tests/functional/largest_pool/largest_pool.cfg | |
34 | ||
35 | # DESCRIPTION: | |
36 | # The largest pool can be created and a dataset in that | |
37 | # pool can be created and mounted. | |
38 | # | |
39 | # STRATEGY: | |
40 | # create a pool which will contain a volume device. | |
41 | # create a volume device of desired sizes. | |
42 | # create the largest pool allowed using the volume vdev. | |
43 | # create and mount a dataset in the largest pool. | |
44 | # create some files in the zfs file system. | |
45 | # do some zpool list commands and parse the output. | |
46 | ||
47 | verify_runnable "global" | |
48 | ||
49 | # | |
50 | # Parse the results of zpool & zfs creation with specified size | |
51 | # | |
52 | # $1: volume size | |
53 | # | |
54 | # return value: | |
55 | # 0 -> success | |
56 | # 1 -> failure | |
57 | # | |
58 | function parse_expected_output | |
59 | { | |
c1d9abf9 | 60 | UNITS=`echo $1 | sed -e 's/^\([0-9].*\)\([a-z].\)/\2/'` |
6bb24f4d BB |
61 | case "$UNITS" in |
62 | 'mb') CHKUNIT="M" ;; | |
63 | 'gb') CHKUNIT="G" ;; | |
64 | 'tb') CHKUNIT="T" ;; | |
65 | 'pb') CHKUNIT="P" ;; | |
66 | 'eb') CHKUNIT="E" ;; | |
67 | *) CHKUNIT="M" ;; | |
68 | esac | |
69 | ||
70 | log_note "Detect zpool $TESTPOOL in this test machine." | |
c1d9abf9 JWK |
71 | log_must eval "zpool list $TESTPOOL > /tmp/j.$$" |
72 | log_must eval "grep $TESTPOOL /tmp/j.$$ | \ | |
73 | awk '{print $2}' | grep $CHKUNIT" | |
6bb24f4d BB |
74 | |
75 | log_note "Detect the file system in this test machine." | |
c1d9abf9 JWK |
76 | log_must eval "df -F zfs -h > /tmp/j.$$" |
77 | log_must eval "grep $TESTPOOL /tmp/j.$$ | \ | |
78 | awk '{print $2}' | grep $CHKUNIT" | |
6bb24f4d BB |
79 | |
80 | return 0 | |
81 | } | |
82 | ||
83 | # | |
84 | # Check and destroy zfs, volume & zpool remove the temporary files | |
85 | # | |
86 | function cleanup | |
87 | { | |
88 | log_note "Start cleanup the zfs and pool" | |
89 | ||
90 | if datasetexists $TESTPOOL/$TESTFS ; then | |
91 | if ismounted $TESTPOOL/$TESTFS ; then | |
c1d9abf9 | 92 | log_must zfs unmount $TESTPOOL/$TESTFS |
6bb24f4d | 93 | fi |
c1d9abf9 | 94 | log_must zfs destroy $TESTPOOL/$TESTFS |
6bb24f4d BB |
95 | fi |
96 | ||
97 | destroy_pool $TESTPOOL | |
98 | ||
99 | datasetexists $TESTPOOL2/$TESTVOL && \ | |
c1d9abf9 | 100 | log_must zfs destroy $TESTPOOL2/$TESTVOL |
6bb24f4d BB |
101 | |
102 | destroy_pool $TESTPOOL2 | |
103 | ||
c1d9abf9 | 104 | rm -f /tmp/j.* > /dev/null |
6bb24f4d BB |
105 | } |
106 | ||
107 | log_assert "The largest pool can be created and a dataset in that" \ | |
108 | "pool can be created and mounted." | |
109 | ||
110 | # Set trigger. When the test case exit, cleanup is executed. | |
111 | log_onexit cleanup | |
112 | ||
113 | # ----------------------------------------------------------------------- | |
114 | # volume sizes with unit designations. | |
115 | # | |
116 | # Note: specifying the number '1' as size will not give the correct | |
117 | # units for 'df'. It must be greater than one. | |
118 | # ----------------------------------------------------------------------- | |
119 | typeset str | |
120 | typeset -i ret | |
121 | for volsize in $VOLSIZES; do | |
122 | log_note "Create a pool which will contain a volume device" | |
123 | create_pool $TESTPOOL2 "$DISKS" | |
124 | ||
125 | log_note "Create a volume device of desired sizes: $volsize" | |
c1d9abf9 | 126 | str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1) |
6bb24f4d BB |
127 | ret=$? |
128 | if (( ret != 0 )); then | |
61f9b2cd | 129 | if [[ is_32bit && \ |
6bb24f4d BB |
130 | $str == *${VOL_LIMIT_KEYWORD1}* || \ |
131 | $str == *${VOL_LIMIT_KEYWORD2}* || \ | |
132 | $str == *${VOL_LIMIT_KEYWORD3}* ]] | |
133 | then | |
134 | log_unsupported \ | |
135 | "Max volume size is 1TB on 32-bit systems." | |
136 | else | |
c1d9abf9 | 137 | log_fail "zfs create -sV $volsize $TESTPOOL2/$TESTVOL" |
6bb24f4d BB |
138 | fi |
139 | fi | |
95401cb6 | 140 | block_device_wait |
6bb24f4d BB |
141 | |
142 | log_note "Create the largest pool allowed using the volume vdev" | |
143 | create_pool $TESTPOOL "$VOL_PATH" | |
144 | ||
145 | log_note "Create a zfs file system in the largest pool" | |
c1d9abf9 | 146 | log_must zfs create $TESTPOOL/$TESTFS |
6bb24f4d BB |
147 | |
148 | log_note "Parse the execution result" | |
149 | parse_expected_output $volsize | |
150 | ||
151 | log_note "unmount this zfs file system $TESTPOOL/$TESTFS" | |
c1d9abf9 | 152 | log_must zfs unmount $TESTPOOL/$TESTFS |
6bb24f4d BB |
153 | |
154 | log_note "Destroy zfs, volume & zpool" | |
c1d9abf9 | 155 | log_must zfs destroy $TESTPOOL/$TESTFS |
6bb24f4d | 156 | destroy_pool $TESTPOOL |
c1d9abf9 | 157 | log_must zfs destroy $TESTPOOL2/$TESTVOL |
6bb24f4d BB |
158 | destroy_pool $TESTPOOL2 |
159 | done | |
160 | ||
161 | log_pass "Dateset can be created, mounted & destroy in largest pool succeeded." |