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