t_raid.sh revision 1.4 1 1.4 pooka # $NetBSD: t_raid.sh,v 1.4 2010/12/18 09:44:41 pooka Exp $
2 1.1 pooka #
3 1.1 pooka # Copyright (c) 2010 The NetBSD Foundation, Inc.
4 1.1 pooka # All rights reserved.
5 1.1 pooka #
6 1.1 pooka # Redistribution and use in source and binary forms, with or without
7 1.1 pooka # modification, are permitted provided that the following conditions
8 1.1 pooka # are met:
9 1.1 pooka # 1. Redistributions of source code must retain the above copyright
10 1.1 pooka # notice, this list of conditions and the following disclaimer.
11 1.1 pooka # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 pooka # notice, this list of conditions and the following disclaimer in the
13 1.1 pooka # documentation and/or other materials provided with the distribution.
14 1.1 pooka #
15 1.1 pooka # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 pooka # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 pooka # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 pooka # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 pooka # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 pooka # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 pooka # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 pooka # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 pooka # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 pooka # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 pooka # POSSIBILITY OF SUCH DAMAGE.
26 1.1 pooka #
27 1.1 pooka
28 1.3 pooka rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'`
29 1.3 pooka rawraid=/dev/rraid0${rawpart}
30 1.3 pooka
31 1.1 pooka makecfg()
32 1.1 pooka {
33 1.1 pooka level=${1}
34 1.1 pooka ncol=${2}
35 1.1 pooka
36 1.1 pooka printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf
37 1.1 pooka diskn=0
38 1.1 pooka while [ ${ncol} -gt ${diskn} ] ; do
39 1.1 pooka echo "/disk${diskn}" >> raid.conf
40 1.1 pooka diskn=$((diskn+1))
41 1.1 pooka done
42 1.1 pooka
43 1.1 pooka printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
44 1.1 pooka >> raid.conf
45 1.1 pooka }
46 1.1 pooka
47 1.1 pooka atf_test_case smalldisk cleanup
48 1.2 pooka smalldisk_head()
49 1.1 pooka {
50 1.3 pooka atf_set "descr" "Checks the raidframe works on small disks " \
51 1.3 pooka "(PR kern/44239)"
52 1.1 pooka }
53 1.1 pooka
54 1.1 pooka smalldisk_body()
55 1.1 pooka {
56 1.1 pooka makecfg 1 2
57 1.1 pooka export RUMP_SERVER=unix://sock
58 1.1 pooka atf_check -s exit:0 rump_allserver \
59 1.1 pooka -d key=/disk0,hostpath=disk0.img,size=1m \
60 1.1 pooka -d key=/disk1,hostpath=disk1.img,size=1m \
61 1.1 pooka ${RUMP_SERVER}
62 1.1 pooka
63 1.1 pooka atf_expect_fail "PR kern/44239" # ADJUST CLEANUP WHEN THIS IS FIXED!
64 1.1 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
65 1.1 pooka }
66 1.1 pooka
67 1.1 pooka smalldisk_cleanup()
68 1.1 pooka {
69 1.1 pooka export RUMP_SERVER=unix://sock
70 1.1 pooka rump.halt
71 1.1 pooka : server dumps currently, so reset error. remove this line when fixed
72 1.1 pooka }
73 1.1 pooka
74 1.4 pooka
75 1.3 pooka # make this smaller once 44239 is fixed
76 1.3 pooka export RAID_MEDIASIZE=32m
77 1.3 pooka
78 1.3 pooka atf_test_case raid1_compfail cleanup
79 1.3 pooka raid1_compfail_head()
80 1.3 pooka {
81 1.3 pooka atf_set "descr" "Checks that RAID1 works after component failure"
82 1.3 pooka }
83 1.3 pooka
84 1.3 pooka raid1_compfail_body()
85 1.3 pooka {
86 1.3 pooka makecfg 1 2
87 1.3 pooka export RUMP_SERVER=unix://sock
88 1.3 pooka atf_check -s exit:0 rump_allserver \
89 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
90 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
91 1.3 pooka ${RUMP_SERVER}
92 1.3 pooka
93 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
94 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
95 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
96 1.3 pooka
97 1.3 pooka # put some data there
98 1.3 pooka atf_check -s exit:0 -e ignore \
99 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
100 1.3 pooka atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
101 1.3 pooka
102 1.3 pooka # restart server with failed component
103 1.3 pooka rump.halt
104 1.3 pooka rm disk1.img # FAIL
105 1.3 pooka atf_check -s exit:0 rump_allserver \
106 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
107 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
108 1.3 pooka ${RUMP_SERVER}
109 1.3 pooka
110 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
111 1.3 pooka
112 1.3 pooka # check if we we get what we wrote
113 1.3 pooka atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
114 1.3 pooka }
115 1.3 pooka
116 1.3 pooka raid1_compfail_cleanup()
117 1.3 pooka {
118 1.4 pooka export RUMP_SERVER=unix://sock
119 1.4 pooka rump.halt
120 1.4 pooka }
121 1.4 pooka
122 1.4 pooka
123 1.4 pooka
124 1.4 pooka atf_test_case raid1_comp0fail cleanup
125 1.4 pooka raid1_comp0fail_head()
126 1.4 pooka {
127 1.4 pooka atf_set "descr" "Checks configuring RAID1 after component 0 fails"
128 1.4 pooka }
129 1.3 pooka
130 1.4 pooka raid1_comp0fail_body()
131 1.4 pooka {
132 1.4 pooka makecfg 1 2
133 1.3 pooka export RUMP_SERVER=unix://sock
134 1.4 pooka atf_check -s exit:0 rump_allserver \
135 1.4 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
136 1.4 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
137 1.4 pooka ${RUMP_SERVER}
138 1.4 pooka
139 1.4 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
140 1.4 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
141 1.4 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
142 1.4 pooka
143 1.4 pooka # restart server with failed component
144 1.3 pooka rump.halt
145 1.4 pooka rm disk0.img # FAIL
146 1.4 pooka atf_check -s exit:0 rump_allserver \
147 1.4 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
148 1.4 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
149 1.4 pooka ${RUMP_SERVER}
150 1.4 pooka
151 1.4 pooka atf_expect_fail "PR kern/44251"
152 1.4 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
153 1.3 pooka }
154 1.3 pooka
155 1.4 pooka raid1_comp0fail_cleanup()
156 1.4 pooka {
157 1.4 pooka export RUMP_SERVER=unix://sock
158 1.4 pooka rump.halt
159 1.4 pooka }
160 1.4 pooka
161 1.4 pooka
162 1.3 pooka atf_test_case raid5_compfail cleanup
163 1.3 pooka raid5_compfail_head()
164 1.3 pooka {
165 1.3 pooka atf_set "descr" "Checks that RAID5 works after component failure"
166 1.3 pooka }
167 1.3 pooka
168 1.3 pooka raid5_compfail_body()
169 1.3 pooka {
170 1.3 pooka makecfg 5 3
171 1.3 pooka export RUMP_SERVER=unix://sock
172 1.3 pooka atf_check -s exit:0 rump_allserver \
173 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
174 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
175 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
176 1.3 pooka ${RUMP_SERVER}
177 1.3 pooka
178 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
179 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
180 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
181 1.3 pooka
182 1.3 pooka # put some data there
183 1.3 pooka atf_check -s exit:0 -e ignore \
184 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
185 1.3 pooka atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
186 1.3 pooka
187 1.3 pooka # restart server with failed component
188 1.3 pooka rump.halt
189 1.3 pooka rm disk2.img # FAIL
190 1.3 pooka atf_check -s exit:0 rump_allserver \
191 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
192 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
193 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
194 1.3 pooka ${RUMP_SERVER}
195 1.3 pooka
196 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
197 1.3 pooka
198 1.3 pooka # check if we we get what we wrote
199 1.3 pooka atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
200 1.3 pooka }
201 1.3 pooka
202 1.3 pooka raid5_compfail_cleanup()
203 1.3 pooka {
204 1.3 pooka export RUMP_SERVER=unix://sock
205 1.3 pooka rump.halt
206 1.3 pooka }
207 1.3 pooka
208 1.4 pooka
209 1.1 pooka atf_init_test_cases()
210 1.1 pooka {
211 1.1 pooka atf_add_test_case smalldisk
212 1.4 pooka atf_add_test_case raid1_comp0fail
213 1.3 pooka atf_add_test_case raid1_compfail
214 1.3 pooka atf_add_test_case raid5_compfail
215 1.1 pooka }
216