xref: /freebsd/tools/regression/zfs/zpool/add/cache.t (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
1#!/bin/sh
2# $FreeBSD$
3
4dir=`dirname $0`
5. ${dir}/../../misc.sh
6
7echo "1..33"
8
9disks_create 6
10names_create 1
11
12expect_ok ${ZPOOL} create ${name0} ${disk0}
13expect_fl ${ZPOOL} add ${name0} cache ${disk0}
14expect_ok ${ZPOOL} destroy ${name0}
15expect_fl ${ZPOOL} status -x ${name0}
16
17expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
18expect_fl ${ZPOOL} add ${name0} cache ${disk1}
19expect_ok ${ZPOOL} destroy ${name0}
20expect_fl ${ZPOOL} status -x ${name0}
21
22expect_ok ${ZPOOL} create ${name0} ${disk0}
23expect_ok ${ZPOOL} add ${name0} cache ${disk1}
24exp=`(
25  echo "  pool: ${name0}"
26  echo " state: ONLINE"
27  echo " scrub: none requested"
28  echo "config:"
29  echo "	NAME        STATE   READ WRITE CKSUM"
30  echo "	${name0}    ONLINE     0     0     0"
31  echo "	  ${disk0}  ONLINE     0     0     0"
32  echo "	cache"
33  echo "	  ${disk1}  ONLINE     0     0     0"
34  echo "errors: No known data errors"
35)`
36expect "${exp}" ${ZPOOL} status ${name0}
37expect_ok ${ZPOOL} destroy ${name0}
38expect_fl ${ZPOOL} status -x ${name0}
39
40expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
41expect_ok ${ZPOOL} add ${name0} cache ${disk2}
42exp=`(
43  echo "  pool: ${name0}"
44  echo " state: ONLINE"
45  echo " scrub: none requested"
46  echo "config:"
47  echo "	NAME        STATE   READ WRITE CKSUM"
48  echo "	${name0}    ONLINE     0     0     0"
49  echo "	  ${disk0}  ONLINE     0     0     0"
50  echo "	cache"
51  echo "	  ${disk1}  ONLINE     0     0     0"
52  echo "	  ${disk2}  ONLINE     0     0     0"
53  echo "errors: No known data errors"
54)`
55expect "${exp}" ${ZPOOL} status ${name0}
56expect_ok ${ZPOOL} destroy ${name0}
57expect_fl ${ZPOOL} status -x ${name0}
58
59expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1} cache ${disk2} ${disk3}
60expect_ok ${ZPOOL} add ${name0} cache ${disk4}
61exp=`(
62  echo "  pool: ${name0}"
63  echo " state: ONLINE"
64  echo " scrub: none requested"
65  echo "config:"
66  echo "	NAME          STATE   READ WRITE CKSUM"
67  echo "	${name0}      ONLINE     0     0     0"
68  echo "	  mirror      ONLINE     0     0     0"
69  echo "	    ${disk0}  ONLINE     0     0     0"
70  echo "	    ${disk1}  ONLINE     0     0     0"
71  echo "	cache"
72  echo "	  ${disk2}    ONLINE     0     0     0"
73  echo "	  ${disk3}    ONLINE     0     0     0"
74  echo "	  ${disk4}    ONLINE     0     0     0"
75  echo "errors: No known data errors"
76)`
77expect "${exp}" ${ZPOOL} status ${name0}
78expect_ok ${ZPOOL} destroy ${name0}
79expect_fl ${ZPOOL} status -x ${name0}
80
81expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2} cache ${disk3}
82expect_ok ${ZPOOL} add ${name0} cache ${disk4}
83exp=`(
84  echo "  pool: ${name0}"
85  echo " state: ONLINE"
86  echo " scrub: none requested"
87  echo "config:"
88  echo "	NAME          STATE   READ WRITE CKSUM"
89  echo "	${name0}      ONLINE     0     0     0"
90  echo "	  raidz1      ONLINE     0     0     0"
91  echo "	    ${disk0}  ONLINE     0     0     0"
92  echo "	    ${disk1}  ONLINE     0     0     0"
93  echo "	    ${disk2}  ONLINE     0     0     0"
94  echo "	cache"
95  echo "	  ${disk3}    ONLINE     0     0     0"
96  echo "	  ${disk4}    ONLINE     0     0     0"
97  echo "errors: No known data errors"
98)`
99expect "${exp}" ${ZPOOL} status ${name0}
100expect_ok ${ZPOOL} destroy ${name0}
101expect_fl ${ZPOOL} status -x ${name0}
102
103expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3} cache ${disk4}
104expect_ok ${ZPOOL} add ${name0} cache ${disk5}
105exp=`(
106  echo "  pool: ${name0}"
107  echo " state: ONLINE"
108  echo " scrub: none requested"
109  echo "config:"
110  echo "	NAME          STATE   READ WRITE CKSUM"
111  echo "	${name0}      ONLINE     0     0     0"
112  echo "	  raidz2      ONLINE     0     0     0"
113  echo "	    ${disk0}  ONLINE     0     0     0"
114  echo "	    ${disk1}  ONLINE     0     0     0"
115  echo "	    ${disk2}  ONLINE     0     0     0"
116  echo "	    ${disk3}  ONLINE     0     0     0"
117  echo "	cache"
118  echo "	  ${disk4}    ONLINE     0     0     0"
119  echo "	  ${disk5}    ONLINE     0     0     0"
120  echo "errors: No known data errors"
121)`
122expect "${exp}" ${ZPOOL} status ${name0}
123expect_ok ${ZPOOL} destroy ${name0}
124expect_fl ${ZPOOL} status -x ${name0}
125
126disks_destroy
127