xref: /freebsd/tools/regression/zfs/zpool/replace/raidz1.t (revision a90b9d0159070121c221b966469c3e36d912bf82)
1#!/bin/sh
2
3dir=`dirname $0`
4. ${dir}/../../misc.sh
5
6echo "1..27"
7
8disks_create 4
9names_create 1
10
11expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
12expect_ok ${ZPOOL} export ${name0}
13dname0=${disk0}
14fdname0=${fdisk0}
15guid0=`get_guid ${fdisk0}`
16disk_destroy 0
17disk_create 0 ${dname0}
18expect_ok ${ZPOOL} import ${import_flags} ${name0}
19exp=`(
20  echo "  pool: ${name0}"
21  echo " state: DEGRADED"
22  echo "status: One or more devices could not be used because the label is missing or"
23  echo "      invalid.  Sufficient replicas exist for the pool to continue"
24  echo "      functioning in a degraded state."
25  echo "action: Replace the device using 'zpool replace'."
26  echo "   see: http://www.sun.com/msg/ZFS-8000-4J"
27  echo " scrub: none requested"
28  echo "config:"
29  echo "	NAME          STATE     READ WRITE CKSUM"
30  echo "	${name0}      DEGRADED     0     0     0"
31  echo "	  raidz1      DEGRADED     0     0     0"
32  echo "	    ${guid0}  UNAVAIL      0     0     0 was ${fdname0}"
33  echo "	    ${disk1}  ONLINE       0     0     0"
34  echo "	    ${disk2}  ONLINE       0     0     0"
35  echo "errors: No known data errors"
36)`
37expect "${exp}" ${ZPOOL} status ${name0}
38expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk3}
39wait_for_resilver ${name0}
40exp=`(
41  echo "  pool: ${name0}"
42  echo " state: ONLINE"
43  echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
44  echo "config:"
45  echo "	NAME          STATE   READ WRITE CKSUM"
46  echo "	${name0}      ONLINE     0     0     0"
47  echo "	  raidz1      ONLINE     0     0     0"
48  echo "	    ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
49  echo "	    ${disk1}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
50  echo "	    ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
51  echo "errors: No known data errors"
52)`
53expect "${exp}" ${ZPOOL} status ${name0}
54expect_ok ${ZPOOL} destroy ${name0}
55expect_fl ${ZPOOL} status -x ${name0}
56
57expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
58expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk3}
59wait_for_resilver ${name0}
60exp=`(
61  echo "  pool: ${name0}"
62  echo " state: ONLINE"
63  echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
64  echo "config:"
65  echo "	NAME          STATE   READ WRITE CKSUM"
66  echo "	${name0}      ONLINE     0     0     0"
67  echo "	  raidz1      ONLINE     0     0     0"
68  echo "	    ${disk0}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
69  echo "	    ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
70  echo "	    ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
71  echo "errors: No known data errors"
72)`
73expect "${exp}" ${ZPOOL} status ${name0}
74expect_ok ${ZPOOL} destroy ${name0}
75expect_fl ${ZPOOL} status -x ${name0}
76
77expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
78expect_ok ${ZPOOL} export ${name0}
79dname0=${disk0}
80fdname0=${fdisk0}
81guid0=`get_guid ${fdisk0}`
82disk_destroy 0
83expect_ok ${ZPOOL} import ${import_flags} ${name0}
84exp=`(
85  echo "  pool: ${name0}"
86  echo " state: DEGRADED"
87  echo " scrub: none requested"
88  echo "config:"
89  echo "	NAME           STATE     READ WRITE CKSUM"
90  echo "	${name0}       DEGRADED     0     0     0"
91  echo "	  raidz1       DEGRADED     0     0     0"
92  echo "	    ${guid0}   REMOVED      0     0     0  was ${fdname0}"
93  echo "	    ${disk1}   ONLINE       0     0     0"
94  echo "	    ${disk2}   ONLINE       0     0     0"
95  echo "errors: No known data errors"
96)`
97expect "${exp}" ${ZPOOL} status ${name0}
98expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk3}
99wait_for_resilver ${name0}
100exp=`(
101  echo "  pool: ${name0}"
102  echo " state: ONLINE"
103  echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
104  echo "config:"
105  echo "	NAME          STATE   READ WRITE CKSUM"
106  echo "	${name0}      ONLINE     0     0     0"
107  echo "	  raidz1      ONLINE     0     0     0"
108  echo "	    ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
109  echo "	    ${disk1}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
110  echo "	    ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
111  echo "errors: No known data errors"
112)`
113expect "${exp}" ${ZPOOL} status ${name0}
114expect_ok ${ZPOOL} destroy ${name0}
115expect_fl ${ZPOOL} status -x ${name0}
116disk_create 0 ${dname0}
117
118expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
119expect_ok ${ZPOOL} offline ${name0} ${disk1}
120expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk3}
121wait_for_resilver ${name0}
122exp=`(
123  echo "  pool: ${name0}"
124  echo " state: ONLINE"
125  echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
126  echo "config:"
127  echo "	NAME          STATE   READ WRITE CKSUM"
128  echo "	${name0}      ONLINE     0     0     0"
129  echo "	  raidz1      ONLINE     0     0     0"
130  echo "	    ${disk0}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
131  echo "	    ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
132  echo "	    ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
133  echo "errors: No known data errors"
134)`
135expect "${exp}" ${ZPOOL} status ${name0}
136expect_ok ${ZPOOL} destroy ${name0}
137expect_fl ${ZPOOL} status -x ${name0}
138
139disks_destroy
140