xref: /freebsd/tools/regression/zfs/zpool/replace/log.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} ${disk0} log mirror ${disk1} ${disk2}
12expect_ok ${ZPOOL} export ${name0}
13dname1=${disk1}
14fdname1=${fdisk1}
15guid1=`get_guid ${fdisk1}`
16disk_destroy 1
17disk_create 1 ${dname1}
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 "	  ${disk0}    ONLINE       0     0     0"
32  echo "	logs          DEGRADED     0     0     0"
33  echo "	  mirror      DEGRADED     0     0     0"
34  echo "	    ${guid1}  UNAVAIL      0     0     0 was ${fdname1}"
35  echo "	    ${disk2}  ONLINE       0     0     0"
36  echo "errors: No known data errors"
37)`
38add_msg="# TODO Sun CR 6710376, Lustre bug 16912"
39expect "${exp}" ${ZPOOL} status ${name0}
40add_msg=""
41expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk3}
42wait_for_resilver ${name0}
43exp=`(
44  echo "  pool: ${name0}"
45  echo " state: ONLINE"
46  echo " scrub: resilver completed after [0-9]+h[0-9]+m with 0 errors on .*"
47  echo "config:"
48  echo "	NAME          STATE   READ WRITE CKSUM"
49  echo "	${name0}      ONLINE     0     0     0"
50  echo "	  ${disk0}    ONLINE     0     0     0"
51  echo "	logs          ONLINE     0     0     0"
52  echo "	  mirror      ONLINE     0     0     0"
53  echo "	    ${disk3}  ONLINE     0     0     0"
54  echo "	    ${disk2}  ONLINE     0     0     0"
55  echo "errors: No known data errors"
56)`
57expect "${exp}" ${ZPOOL} status ${name0}
58expect_ok ${ZPOOL} destroy ${name0}
59expect_fl ${ZPOOL} status -x ${name0}
60
61expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
62expect_ok ${ZPOOL} replace ${name0} ${disk2} ${disk3}
63wait_for_resilver ${name0}
64exp=`(
65  echo "  pool: ${name0}"
66  echo " state: ONLINE"
67  echo " scrub: resilver completed after [0-9]+h[0-9]+m with 0 errors on .*"
68  echo "config:"
69  echo "	NAME          STATE   READ WRITE CKSUM"
70  echo "	${name0}      ONLINE     0     0     0"
71  echo "	  ${disk0}    ONLINE     0     0     0"
72  echo "	logs          ONLINE     0     0     0"
73  echo "	  mirror      ONLINE     0     0     0"
74  echo "	    ${disk1}  ONLINE     0     0     0"
75  echo "	    ${disk3}  ONLINE     0     0     0"
76  echo "errors: No known data errors"
77)`
78expect "${exp}" ${ZPOOL} status ${name0}
79expect_ok ${ZPOOL} destroy ${name0}
80expect_fl ${ZPOOL} status -x ${name0}
81
82expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
83expect_ok ${ZPOOL} export ${name0}
84dname1=${disk1}
85fdname1=${fdisk1}
86guid1=`get_guid ${fdisk1}`
87disk_destroy 1
88expect_ok ${ZPOOL} import ${import_flags} ${name0}
89exp=`(
90  echo "  pool: ${name0}"
91  echo " state: DEGRADED"
92  echo "status: One or more devices could not be opened.  Sufficient replicas exist for"
93  echo "      the pool to continue functioning in a degraded state."
94  echo "action: Attach the missing device and online it using 'zpool online'."
95  echo "   see: http://www.sun.com/msg/ZFS-8000-2Q"
96  echo " scrub: none requested"
97  echo "config:"
98  echo "	NAME           STATE     READ WRITE CKSUM"
99  echo "	${name0}       DEGRADED     0     0     0"
100  echo "	  ${disk0}     ONLINE       0     0     0"
101  echo "	logs           DEGRADED     0     0     0"
102  echo "	  mirror       DEGRADED     0     0     0"
103  echo "	    ${guid1}   UNAVAIL      0     0     0  was ${fdname1}"
104  echo "	    ${disk2}   ONLINE       0     0     0"
105  echo "errors: No known data errors"
106)`
107expect "${exp}" ${ZPOOL} status ${name0}
108expect_ok ${ZPOOL} replace ${name0} ${dname1} ${disk3}
109wait_for_resilver ${name0}
110exp=`(
111  echo "  pool: ${name0}"
112  echo " state: ONLINE"
113  echo " scrub: resilver completed after [0-9]+h[0-9]+m with 0 errors on .*"
114  echo "config:"
115  echo "	NAME          STATE   READ WRITE CKSUM"
116  echo "	${name0}      ONLINE     0     0     0"
117  echo "	  ${disk0}    ONLINE     0     0     0"
118  echo "	logs          ONLINE     0     0     0"
119  echo "	  mirror      ONLINE     0     0     0"
120  echo "	    ${disk3}  ONLINE     0     0     0"
121  echo "	    ${disk2}  ONLINE     0     0     0"
122  echo "errors: No known data errors"
123)`
124expect "${exp}" ${ZPOOL} status ${name0}
125expect_ok ${ZPOOL} destroy ${name0}
126expect_fl ${ZPOOL} status -x ${name0}
127disk_create 1 ${dname1}
128
129expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
130expect_ok ${ZPOOL} offline ${name0} ${disk1}
131expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk3}
132wait_for_resilver ${name0}
133exp=`(
134  echo "  pool: ${name0}"
135  echo " state: ONLINE"
136  echo " scrub: resilver completed after [0-9]+h[0-9]+m with 0 errors on .*"
137  echo "config:"
138  echo "	NAME          STATE   READ WRITE CKSUM"
139  echo "	${name0}      ONLINE     0     0     0"
140  echo "	  ${disk0}    ONLINE     0     0     0"
141  echo "	logs          ONLINE     0     0     0"
142  echo "	  mirror      ONLINE     0     0     0"
143  echo "	    ${disk3}  ONLINE     0     0     0"
144  echo "	    ${disk2}  ONLINE     0     0     0"
145  echo "errors: No known data errors"
146)`
147expect "${exp}" ${ZPOOL} status ${name0}
148expect_ok ${ZPOOL} destroy ${name0}
149expect_fl ${ZPOOL} status -x ${name0}
150
151disks_destroy
152