xref: /freebsd/tools/regression/zfs/zpool/add/spare.t (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1#!/bin/sh
2# $FreeBSD$
3
4dir=`dirname $0`
5. ${dir}/../../misc.sh
6
7echo "1..31"
8
9disks_create 6
10names_create 1
11
12expect_ok ${ZPOOL} create ${name0} ${disk0}
13expect_ok ${ZPOOL} add ${name0} spare ${disk1}
14exp=`(
15  echo "  pool: ${name0}"
16  echo " state: ONLINE"
17  echo " scrub: none requested"
18  echo "config:"
19  echo "	NAME        STATE   READ WRITE CKSUM"
20  echo "	${name0}    ONLINE     0     0     0"
21  echo "	  ${disk0}  ONLINE     0     0     0"
22  echo "	spares"
23  echo "	  ${disk1}  AVAIL"
24  echo "errors: No known data errors"
25)`
26expect "${exp}" ${ZPOOL} status ${name0}
27expect_ok ${ZPOOL} destroy ${name0}
28expect_fl ${ZPOOL} status -x ${name0}
29
30expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
31expect_ok ${ZPOOL} add ${name0} spare ${disk2} ${disk3}
32exp=`(
33  echo "  pool: ${name0}"
34  echo " state: ONLINE"
35  echo " scrub: none requested"
36  echo "config:"
37  echo "	NAME          STATE   READ WRITE CKSUM"
38  echo "	${name0}      ONLINE     0     0     0"
39  echo "	  mirror      ONLINE     0     0     0"
40  echo "	    ${disk0}  ONLINE     0     0     0"
41  echo "	    ${disk1}  ONLINE     0     0     0"
42  echo "	spares"
43  echo "	  ${disk2}    AVAIL"
44  echo "	  ${disk3}    AVAIL"
45  echo "errors: No known data errors"
46)`
47expect "${exp}" ${ZPOOL} status ${name0}
48expect_ok ${ZPOOL} destroy ${name0}
49expect_fl ${ZPOOL} status -x ${name0}
50
51expect_ok ${ZPOOL} create ${name0} raidz ${disk0} ${disk1} ${disk2}
52expect_ok ${ZPOOL} add ${name0} spare ${disk3} ${disk4}
53exp=`(
54  echo "  pool: ${name0}"
55  echo " state: ONLINE"
56  echo " scrub: none requested"
57  echo "config:"
58  echo "	NAME          STATE   READ WRITE CKSUM"
59  echo "	${name0}      ONLINE     0     0     0"
60  echo "	  raidz1      ONLINE     0     0     0"
61  echo "	    ${disk0}  ONLINE     0     0     0"
62  echo "	    ${disk1}  ONLINE     0     0     0"
63  echo "	    ${disk2}  ONLINE     0     0     0"
64  echo "	spares"
65  echo "	  ${disk3}    AVAIL"
66  echo "	  ${disk4}    AVAIL"
67  echo "errors: No known data errors"
68)`
69expect "${exp}" ${ZPOOL} status ${name0}
70expect_ok ${ZPOOL} destroy ${name0}
71expect_fl ${ZPOOL} status -x ${name0}
72
73expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
74expect_ok ${ZPOOL} add ${name0} spare ${disk4} ${disk5}
75exp=`(
76  echo "  pool: ${name0}"
77  echo " state: ONLINE"
78  echo " scrub: none requested"
79  echo "config:"
80  echo "	NAME          STATE   READ WRITE CKSUM"
81  echo "	${name0}      ONLINE     0     0     0"
82  echo "	  raidz2      ONLINE     0     0     0"
83  echo "	    ${disk0}  ONLINE     0     0     0"
84  echo "	    ${disk1}  ONLINE     0     0     0"
85  echo "	    ${disk2}  ONLINE     0     0     0"
86  echo "	    ${disk3}  ONLINE     0     0     0"
87  echo "	spares"
88  echo "	  ${disk4}    AVAIL"
89  echo "	  ${disk5}    AVAIL"
90  echo "errors: No known data errors"
91)`
92expect "${exp}" ${ZPOOL} status ${name0}
93expect_ok ${ZPOOL} destroy ${name0}
94expect_fl ${ZPOOL} status -x ${name0}
95
96expect_ok ${ZPOOL} create ${name0} ${disk0} spare ${disk1}
97expect_ok ${ZPOOL} add ${name0} spare ${disk2} ${disk3}
98exp=`(
99  echo "  pool: ${name0}"
100  echo " state: ONLINE"
101  echo " scrub: none requested"
102  echo "config:"
103  echo "	NAME        STATE   READ WRITE CKSUM"
104  echo "	${name0}    ONLINE     0     0     0"
105  echo "	  ${disk0}  ONLINE     0     0     0"
106  echo "	spares"
107  echo "	  ${disk1}  AVAIL"
108  echo "	  ${disk2}  AVAIL"
109  echo "	  ${disk3}  AVAIL"
110  echo "errors: No known data errors"
111)`
112expect "${exp}" ${ZPOOL} status ${name0}
113expect_ok ${ZPOOL} destroy ${name0}
114expect_fl ${ZPOOL} status -x ${name0}
115
116expect_ok ${ZPOOL} create ${name0} ${disk0}
117expect_ok ${ZPOOL} add ${name0} spare ${disk1} ${disk2}
118expect_ok ${ZPOOL} add ${name0} spare ${disk3}
119exp=`(
120  echo "  pool: ${name0}"
121  echo " state: ONLINE"
122  echo " scrub: none requested"
123  echo "config:"
124  echo "	NAME        STATE   READ WRITE CKSUM"
125  echo "	${name0}    ONLINE     0     0     0"
126  echo "	  ${disk0}  ONLINE     0     0     0"
127  echo "	spares"
128  echo "	  ${disk1}  AVAIL"
129  echo "	  ${disk2}  AVAIL"
130  echo "	  ${disk3}  AVAIL"
131  echo "errors: No known data errors"
132)`
133expect "${exp}" ${ZPOOL} status ${name0}
134expect_ok ${ZPOOL} destroy ${name0}
135expect_fl ${ZPOOL} status -x ${name0}
136
137disks_destroy
138