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