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