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