xref: /freebsd/tools/regression/zfs/zpool/remove/spare.t (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1#!/bin/sh
2
3dir=`dirname $0`
4. ${dir}/../../misc.sh
5
6echo "1..18"
7
8disks_create 4
9files_create 4
10names_create 1
11
12expect_ok ${ZPOOL} create ${name0} ${disk0} spare ${disk1}
13expect_ok ${ZPOOL} add ${name0} spare ${disk2} ${disk3}
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 "	  ${disk2}  AVAIL"
25  echo "	  ${disk3}  AVAIL"
26  echo "errors: No known data errors"
27)`
28expect "${exp}" ${ZPOOL} status ${name0}
29expect_ok ${ZPOOL} remove ${name0} ${disk1} ${disk2}
30exp=`(
31  echo "  pool: ${name0}"
32  echo " state: ONLINE"
33  echo " scrub: none requested"
34  echo "config:"
35  echo "	NAME        STATE   READ WRITE CKSUM"
36  echo "	${name0}    ONLINE     0     0     0"
37  echo "	  ${disk0}  ONLINE     0     0     0"
38  echo "	spares"
39  echo "	  ${disk3}  AVAIL"
40  echo "errors: No known data errors"
41)`
42expect "${exp}" ${ZPOOL} status ${name0}
43expect_ok ${ZPOOL} remove ${name0} ${disk3}
44exp=`(
45  echo "  pool: ${name0}"
46  echo " state: ONLINE"
47  echo " scrub: none requested"
48  echo "config:"
49  echo "	NAME        STATE   READ WRITE CKSUM"
50  echo "	${name0}    ONLINE     0     0     0"
51  echo "	  ${disk0}  ONLINE     0     0     0"
52  echo "errors: No known data errors"
53)`
54expect "${exp}" ${ZPOOL} status ${name0}
55expect_ok ${ZPOOL} destroy ${name0}
56expect_fl ${ZPOOL} status -x ${name0}
57
58expect_ok ${ZPOOL} create ${name0} ${file0} spare ${file1}
59expect_ok ${ZPOOL} add ${name0} spare ${file2} ${file3}
60exp=`(
61  echo "  pool: ${name0}"
62  echo " state: ONLINE"
63  echo " scrub: none requested"
64  echo "config:"
65  echo "	NAME        STATE   READ WRITE CKSUM"
66  echo "	${name0}    ONLINE     0     0     0"
67  echo "	  ${file0}  ONLINE     0     0     0"
68  echo "	spares"
69  echo "	  ${file1}  AVAIL"
70  echo "	  ${file2}  AVAIL"
71  echo "	  ${file3}  AVAIL"
72  echo "errors: No known data errors"
73)`
74expect "${exp}" ${ZPOOL} status ${name0}
75expect_ok ${ZPOOL} remove ${name0} ${file1} ${file2}
76exp=`(
77  echo "  pool: ${name0}"
78  echo " state: ONLINE"
79  echo " scrub: none requested"
80  echo "config:"
81  echo "	NAME        STATE   READ WRITE CKSUM"
82  echo "	${name0}    ONLINE     0     0     0"
83  echo "	  ${file0}  ONLINE     0     0     0"
84  echo "	spares"
85  echo "	  ${file3}  AVAIL"
86  echo "errors: No known data errors"
87)`
88expect "${exp}" ${ZPOOL} status ${name0}
89expect_ok ${ZPOOL} remove ${name0} ${file3}
90exp=`(
91  echo "  pool: ${name0}"
92  echo " state: ONLINE"
93  echo " scrub: none requested"
94  echo "config:"
95  echo "	NAME        STATE   READ WRITE CKSUM"
96  echo "	${name0}    ONLINE     0     0     0"
97  echo "	  ${file0}  ONLINE     0     0     0"
98  echo "errors: No known data errors"
99)`
100expect "${exp}" ${ZPOOL} status ${name0}
101expect_ok ${ZPOOL} destroy ${name0}
102expect_fl ${ZPOOL} status -x ${name0}
103
104files_destroy
105disks_destroy
106