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