]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/zfs/zpool/replace/mirror.t
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / zfs / zpool / replace / mirror.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 dir=`dirname $0`
5 . ${dir}/../../misc.sh
6
7 echo "1..27"
8
9 disks_create 3
10 names_create 1
11
12 expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
13 expect_ok ${ZPOOL} export ${name0}
14 dname0=${disk0}
15 fdname0=${fdisk0}
16 guid0=`get_guid ${fdisk0}`
17 disk_destroy 0
18 disk_create 0 ${dname0}
19 expect_ok ${ZPOOL} import ${import_flags} ${name0}
20 exp=`(
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 "          mirror      DEGRADED     0     0     0"
33   echo "            ${guid0}  UNAVAIL      0     0     0 was ${fdname0}"
34   echo "            ${disk1}  ONLINE       0     0     0"
35   echo "errors: No known data errors"
36 )`
37 expect "${exp}" ${ZPOOL} status ${name0}
38 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk2}
39 wait_for_resilver ${name0}
40 exp=`(
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 "          mirror      ONLINE     0     0     0"
48   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
49   echo "            ${disk1}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
50   echo "errors: No known data errors"
51 )`
52 expect "${exp}" ${ZPOOL} status ${name0}
53 expect_ok ${ZPOOL} destroy ${name0}
54 expect_fl ${ZPOOL} status -x ${name0}
55
56 expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
57 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk2}
58 wait_for_resilver ${name0}
59 exp=`(
60   echo "  pool: ${name0}"
61   echo " state: ONLINE"
62   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
63   echo "config:"
64   echo "        NAME          STATE   READ WRITE CKSUM"
65   echo "        ${name0}      ONLINE     0     0     0"
66   echo "          mirror      ONLINE     0     0     0"
67   echo "            ${disk0}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
68   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
69   echo "errors: No known data errors"
70 )`
71 expect "${exp}" ${ZPOOL} status ${name0}
72 expect_ok ${ZPOOL} destroy ${name0}
73 expect_fl ${ZPOOL} status -x ${name0}
74
75 expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
76 expect_ok ${ZPOOL} export ${name0}
77 dname0=${disk0}
78 fdname0=${fdisk0}
79 guid0=`get_guid ${fdisk0}`
80 disk_destroy 0
81 expect_ok ${ZPOOL} import ${import_flags} ${name0}
82 exp=`(
83   echo "  pool: ${name0}"
84   echo " state: DEGRADED"
85   echo " scrub: none requested"
86   echo "config:"
87   echo "        NAME           STATE     READ WRITE CKSUM"
88   echo "        ${name0}       DEGRADED     0     0     0"
89   echo "          mirror       DEGRADED     0     0     0"
90   echo "            ${guid0}   REMOVED      0     0     0  was ${fdname0}"
91   echo "            ${disk1}   ONLINE       0     0     0"
92   echo "errors: No known data errors"
93 )`
94 expect "${exp}" ${ZPOOL} status ${name0}
95 expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk2}
96 wait_for_resilver ${name0}
97 exp=`(
98   echo "  pool: ${name0}"
99   echo " state: ONLINE"
100   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
101   echo "config:"
102   echo "        NAME          STATE   READ WRITE CKSUM"
103   echo "        ${name0}      ONLINE     0     0     0"
104   echo "          mirror      ONLINE     0     0     0"
105   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
106   echo "            ${disk1}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
107   echo "errors: No known data errors"
108 )`
109 expect "${exp}" ${ZPOOL} status ${name0}
110 expect_ok ${ZPOOL} destroy ${name0}
111 expect_fl ${ZPOOL} status -x ${name0}
112 disk_create 0 ${dname0}
113
114 expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
115 expect_ok ${ZPOOL} offline ${name0} ${disk1}
116 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk2}
117 wait_for_resilver ${name0}
118 exp=`(
119   echo "  pool: ${name0}"
120   echo " state: ONLINE"
121   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
122   echo "config:"
123   echo "        NAME          STATE   READ WRITE CKSUM"
124   echo "        ${name0}      ONLINE     0     0     0"
125   echo "          mirror      ONLINE     0     0     0"
126   echo "            ${disk0}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
127   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
128   echo "errors: No known data errors"
129 )`
130 expect "${exp}" ${ZPOOL} status ${name0}
131 expect_ok ${ZPOOL} destroy ${name0}
132 expect_fl ${ZPOOL} status -x ${name0}
133
134 disks_destroy