Mercurial > illumos > illumos-gate
annotate usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh @ 13899:0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
3312 Add a testrunner package for OS unit tests
3313 Add a testrunner package to convert ZFS tests from STF
Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by: Will Guyette <will.guyette@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Henrik Mattson <henrik.mattson@delphix.com>
Reviewed by: Sonu Pillai <sonu.pillai@delphix.com>
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | John Wren Kennedy <john.kennedy@delphix.com> |
---|---|
date | Wed, 05 Dec 2012 22:04:50 -0500 |
parents | |
children |
rev | line source |
---|---|
13899
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
1 #!/usr/bin/ksh -p |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
2 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
3 # CDDL HEADER START |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
4 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
5 # The contents of this file are subject to the terms of the |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
6 # Common Development and Distribution License (the "License"). |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
7 # You may not use this file except in compliance with the License. |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
8 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
10 # or http://www.opensolaris.org/os/licensing. |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
11 # See the License for the specific language governing permissions |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
12 # and limitations under the License. |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
13 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
14 # When distributing Covered Code, include this CDDL HEADER in each |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
16 # If applicable, add the following below this CDDL HEADER, with the |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
17 # fields enclosed by brackets "[]" replaced with your own identifying |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
19 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
20 # CDDL HEADER END |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
21 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
22 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
23 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
25 # Use is subject to license terms. |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
26 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
27 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
28 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
29 # Copyright (c) 2012 by Delphix. All rights reserved. |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
30 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
31 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
32 . $STF_SUITE/include/libtest.shlib |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
33 . $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.cfg |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
34 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
35 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
36 # DESCRIPTION: |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
37 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
38 # zpool create -R works as expected |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
39 # |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
40 # STRATEGY: |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
41 # 1. Create a -R altroot pool |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
42 # 2. Verify the pool is mounted at the correct location |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
43 # 3. Verify that cachefile=none for the pool |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
44 # 4. Verify that root=<mountpoint> for the pool |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
45 # 5. Verify that no reference to the pool is found in /etc/zfs/zpool.cache |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
46 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
47 function cleanup |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
48 { |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
49 if poolexists $TESTPOOL ; then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
50 destroy_pool $TESTPOOL |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
51 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
52 if [ -d ${TESTPOOL}.root ] |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
53 then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
54 log_must $RMDIR ${TESTPOOL}.root |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
55 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
56 } |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
57 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
58 log_onexit cleanup |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
59 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
60 log_assert "zpool create -R works as expected" |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
61 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
62 if [[ -n $DISK ]]; then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
63 disk=$DISK |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
64 else |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
65 disk=$DISK0 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
66 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
67 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
68 log_must $MKDIR /${TESTPOOL}.root |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
69 log_must $ZPOOL create -R /${TESTPOOL}.root $TESTPOOL $disk |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
70 if [ ! -d /${TESTPOOL}.root ] |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
71 then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
72 log_fail "Mountpoint was not create when using zpool with -R flag!" |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
73 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
74 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
75 FS=$($ZFS list $TESTPOOL) |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
76 if [ -z "$FS" ] |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
77 then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
78 log_fail "Mounted filesystem at /${TESTPOOL}.root isn't ZFS!" |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
79 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
80 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
81 log_must $ZPOOL get all $TESTPOOL |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
82 $ZPOOL get all $TESTPOOL > /tmp/values.$$ |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
83 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
84 # check for the cachefile property, verifying that it's set to 'none' |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
85 $GREP "$TESTPOOL[ ]*cachefile[ ]*none" /tmp/values.$$ > /dev/null 2>&1 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
86 if [ $? -ne 0 ] |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
87 then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
88 log_fail "zpool property \'cachefile\' was not set to \'none\'." |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
89 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
90 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
91 # check that the root = /mountpoint property is set correctly |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
92 $GREP "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" /tmp/values.$$ > /dev/null 2>&1 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
93 if [ $? -ne 0 ] |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
94 then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
95 log_fail "zpool property root was not found in pool output." |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
96 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
97 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
98 $RM /tmp/values.$$ |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
99 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
100 # finally, check that the pool has no reference in /etc/zfs/zpool.cache |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
101 if [[ -f /etc/zfs/zpool.cache ]] ; then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
102 REF=$($STRINGS /etc/zfs/zpool.cache | $GREP ${TESTPOOL}) |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
103 if [ ! -z "$REF" ] |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
104 then |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
105 $STRINGS /etc/zfs/zpool.cache |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
106 log_fail "/etc/zfs/zpool.cache appears to have a reference to $TESTPOOL" |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
107 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
108 fi |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
109 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
110 |
0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
John Wren Kennedy <john.kennedy@delphix.com>
parents:
diff
changeset
|
111 log_pass "zpool create -R works as expected" |