t_raid.sh revision 1.14 1 1.9 oster #! /usr/bin/atf-sh
2 1.14 martin # $NetBSD: t_raid.sh,v 1.14 2019/07/10 06:10:54 martin Exp $
3 1.1 pooka #
4 1.1 pooka # Copyright (c) 2010 The NetBSD Foundation, Inc.
5 1.1 pooka # All rights reserved.
6 1.1 pooka #
7 1.1 pooka # Redistribution and use in source and binary forms, with or without
8 1.1 pooka # modification, are permitted provided that the following conditions
9 1.1 pooka # are met:
10 1.1 pooka # 1. Redistributions of source code must retain the above copyright
11 1.1 pooka # notice, this list of conditions and the following disclaimer.
12 1.1 pooka # 2. Redistributions in binary form must reproduce the above copyright
13 1.1 pooka # notice, this list of conditions and the following disclaimer in the
14 1.1 pooka # documentation and/or other materials provided with the distribution.
15 1.1 pooka #
16 1.1 pooka # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 pooka # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 pooka # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 pooka # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 pooka # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 pooka # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 pooka # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 pooka # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 pooka # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 pooka # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 pooka # POSSIBILITY OF SUCH DAMAGE.
27 1.1 pooka #
28 1.1 pooka
29 1.3 pooka rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'`
30 1.3 pooka rawraid=/dev/rraid0${rawpart}
31 1.5 pooka raidserver="rump_server -lrumpvfs -lrumpdev -lrumpdev_disk -lrumpdev_raidframe"
32 1.3 pooka
33 1.1 pooka makecfg()
34 1.1 pooka {
35 1.1 pooka level=${1}
36 1.1 pooka ncol=${2}
37 1.1 pooka
38 1.13 mrg printf "START array\n${ncol} 0\nSTART disks\n" > raid.conf
39 1.13 mrg diskn=0
40 1.13 mrg while [ ${ncol} -gt ${diskn} ] ; do
41 1.13 mrg echo "/disk${diskn}" >> raid.conf
42 1.13 mrg diskn=$((diskn+1))
43 1.13 mrg done
44 1.13 mrg
45 1.13 mrg printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
46 1.13 mrg >> raid.conf
47 1.13 mrg }
48 1.13 mrg
49 1.13 mrg makecfg_old()
50 1.13 mrg {
51 1.13 mrg level=${1}
52 1.13 mrg ncol=${2}
53 1.13 mrg
54 1.1 pooka printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf
55 1.1 pooka diskn=0
56 1.1 pooka while [ ${ncol} -gt ${diskn} ] ; do
57 1.1 pooka echo "/disk${diskn}" >> raid.conf
58 1.1 pooka diskn=$((diskn+1))
59 1.1 pooka done
60 1.1 pooka
61 1.1 pooka printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
62 1.1 pooka >> raid.conf
63 1.1 pooka }
64 1.1 pooka
65 1.1 pooka atf_test_case smalldisk cleanup
66 1.2 pooka smalldisk_head()
67 1.1 pooka {
68 1.3 pooka atf_set "descr" "Checks the raidframe works on small disks " \
69 1.3 pooka "(PR kern/44239)"
70 1.12 joerg atf_set "require.progs" "rump_server"
71 1.1 pooka }
72 1.1 pooka
73 1.13 mrg smalldisk_body_backend()
74 1.1 pooka {
75 1.1 pooka export RUMP_SERVER=unix://sock
76 1.5 pooka atf_check -s exit:0 ${raidserver} \
77 1.1 pooka -d key=/disk0,hostpath=disk0.img,size=1m \
78 1.1 pooka -d key=/disk1,hostpath=disk1.img,size=1m \
79 1.1 pooka ${RUMP_SERVER}
80 1.1 pooka
81 1.1 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
82 1.1 pooka }
83 1.1 pooka
84 1.13 mrg smalldisk_body()
85 1.13 mrg {
86 1.13 mrg makecfg 1 2
87 1.13 mrg smalldisk_body_backend
88 1.13 mrg }
89 1.13 mrg
90 1.1 pooka smalldisk_cleanup()
91 1.1 pooka {
92 1.1 pooka export RUMP_SERVER=unix://sock
93 1.1 pooka rump.halt
94 1.1 pooka }
95 1.1 pooka
96 1.13 mrg # The old configuration test case uses the smalldisk backend
97 1.13 mrg atf_test_case old_numrows_config cleanup
98 1.13 mrg old_numrows_config_head()
99 1.13 mrg {
100 1.13 mrg atf_set "descr" "Checks the old numRows configuration works"
101 1.13 mrg atf_set "require.progs" "rump_server"
102 1.13 mrg }
103 1.13 mrg
104 1.13 mrg old_numrows_config_body()
105 1.13 mrg {
106 1.13 mrg makecfg_old 1 2
107 1.13 mrg smalldisk_body_backend
108 1.13 mrg }
109 1.13 mrg
110 1.13 mrg old_numrows_config_cleanup()
111 1.13 mrg {
112 1.13 mrg export RUMP_SERVER=unix://sock
113 1.13 mrg rump.halt
114 1.13 mrg }
115 1.4 pooka
116 1.14 martin export RAID_MEDIASIZE=4m
117 1.3 pooka
118 1.3 pooka atf_test_case raid1_compfail cleanup
119 1.3 pooka raid1_compfail_head()
120 1.3 pooka {
121 1.3 pooka atf_set "descr" "Checks that RAID1 works after component failure"
122 1.12 joerg atf_set "require.progs" "rump_server"
123 1.3 pooka }
124 1.3 pooka
125 1.3 pooka raid1_compfail_body()
126 1.3 pooka {
127 1.3 pooka makecfg 1 2
128 1.3 pooka export RUMP_SERVER=unix://sock
129 1.5 pooka atf_check -s exit:0 ${raidserver} \
130 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
131 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
132 1.3 pooka ${RUMP_SERVER}
133 1.3 pooka
134 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
135 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
136 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
137 1.3 pooka
138 1.3 pooka # put some data there
139 1.3 pooka atf_check -s exit:0 -e ignore \
140 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
141 1.8 jmmv atf_check -s exit:0 -e ignore -x \
142 1.6 pooka "dd if=testfile | rump.dd of=${rawraid} conv=sync"
143 1.3 pooka
144 1.3 pooka # restart server with failed component
145 1.3 pooka rump.halt
146 1.3 pooka rm disk1.img # FAIL
147 1.5 pooka atf_check -s exit:0 ${raidserver} \
148 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
149 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
150 1.3 pooka ${RUMP_SERVER}
151 1.3 pooka
152 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
153 1.3 pooka
154 1.3 pooka # check if we we get what we wrote
155 1.6 pooka atf_check -s exit:0 -o file:testfile -e ignore \
156 1.6 pooka rump.dd if=${rawraid} count=4
157 1.3 pooka }
158 1.3 pooka
159 1.3 pooka raid1_compfail_cleanup()
160 1.3 pooka {
161 1.4 pooka export RUMP_SERVER=unix://sock
162 1.4 pooka rump.halt
163 1.4 pooka }
164 1.4 pooka
165 1.4 pooka
166 1.4 pooka
167 1.4 pooka atf_test_case raid1_comp0fail cleanup
168 1.4 pooka raid1_comp0fail_head()
169 1.4 pooka {
170 1.9 oster atf_set "descr" "Checks configuring RAID1 after component 0 fails" \
171 1.9 oster "(PR kern/44251)"
172 1.12 joerg atf_set "require.progs" "rump_server"
173 1.4 pooka }
174 1.3 pooka
175 1.4 pooka raid1_comp0fail_body()
176 1.4 pooka {
177 1.4 pooka makecfg 1 2
178 1.3 pooka export RUMP_SERVER=unix://sock
179 1.5 pooka atf_check -s exit:0 ${raidserver} \
180 1.4 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
181 1.4 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
182 1.4 pooka ${RUMP_SERVER}
183 1.4 pooka
184 1.4 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
185 1.4 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
186 1.4 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
187 1.4 pooka
188 1.4 pooka # restart server with failed component
189 1.3 pooka rump.halt
190 1.4 pooka rm disk0.img # FAIL
191 1.9 oster atf_check -s exit:0 ${raidserver} \
192 1.4 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
193 1.4 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
194 1.4 pooka ${RUMP_SERVER}
195 1.4 pooka
196 1.4 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
197 1.3 pooka }
198 1.3 pooka
199 1.4 pooka raid1_comp0fail_cleanup()
200 1.4 pooka {
201 1.4 pooka export RUMP_SERVER=unix://sock
202 1.4 pooka rump.halt
203 1.4 pooka }
204 1.4 pooka
205 1.9 oster atf_test_case raid1_normal cleanup
206 1.9 oster raid1_normal_head()
207 1.9 oster {
208 1.9 oster atf_set "descr" "Checks that RAID1 -c configurations work " \
209 1.9 oster "in the normal case"
210 1.12 joerg atf_set "require.progs" "rump_server"
211 1.9 oster }
212 1.9 oster
213 1.9 oster raid1_normal_body()
214 1.9 oster {
215 1.9 oster makecfg 1 2
216 1.10 martin export RUMP_SERVER=unix://sock
217 1.9 oster atf_check -s exit:0 ${raidserver} \
218 1.9 oster -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
219 1.9 oster -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
220 1.9 oster ${RUMP_SERVER}
221 1.9 oster
222 1.9 oster atf_check -s exit:0 rump.raidctl -C raid.conf raid0
223 1.9 oster atf_check -s exit:0 rump.raidctl -I 12345 raid0
224 1.9 oster atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
225 1.9 oster
226 1.9 oster # put some data there
227 1.9 oster atf_check -s exit:0 -e ignore \
228 1.9 oster dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
229 1.9 oster atf_check -s exit:0 -e ignore -x \
230 1.9 oster "dd if=testfile | rump.dd of=${rawraid} conv=sync"
231 1.9 oster
232 1.9 oster # restart server, disks remain normal
233 1.9 oster rump.halt
234 1.9 oster
235 1.9 oster atf_check -s exit:0 ${raidserver} \
236 1.9 oster -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
237 1.9 oster -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
238 1.9 oster ${RUMP_SERVER}
239 1.9 oster
240 1.9 oster atf_check -s exit:0 rump.raidctl -c raid.conf raid0
241 1.9 oster
242 1.9 oster # check if we we get what we wrote
243 1.9 oster atf_check -s exit:0 -o file:testfile -e ignore \
244 1.9 oster rump.dd if=${rawraid} count=4
245 1.9 oster
246 1.9 oster }
247 1.9 oster
248 1.11 gson raid1_normal_cleanup()
249 1.9 oster {
250 1.9 oster export RUMP_SERVER=unix://sock
251 1.9 oster rump.halt
252 1.9 oster }
253 1.9 oster
254 1.4 pooka
255 1.3 pooka atf_test_case raid5_compfail cleanup
256 1.3 pooka raid5_compfail_head()
257 1.3 pooka {
258 1.3 pooka atf_set "descr" "Checks that RAID5 works after component failure"
259 1.12 joerg atf_set "require.progs" "rump_server"
260 1.3 pooka }
261 1.3 pooka
262 1.3 pooka raid5_compfail_body()
263 1.3 pooka {
264 1.3 pooka makecfg 5 3
265 1.3 pooka export RUMP_SERVER=unix://sock
266 1.5 pooka atf_check -s exit:0 ${raidserver} \
267 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
268 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
269 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
270 1.3 pooka ${RUMP_SERVER}
271 1.3 pooka
272 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
273 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
274 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
275 1.3 pooka
276 1.3 pooka # put some data there
277 1.3 pooka atf_check -s exit:0 -e ignore \
278 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
279 1.8 jmmv atf_check -s exit:0 -e ignore -x \
280 1.6 pooka "dd if=testfile | rump.dd of=${rawraid} conv=sync"
281 1.3 pooka
282 1.3 pooka # restart server with failed component
283 1.3 pooka rump.halt
284 1.3 pooka rm disk2.img # FAIL
285 1.5 pooka atf_check -s exit:0 ${raidserver} \
286 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
287 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
288 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
289 1.3 pooka ${RUMP_SERVER}
290 1.3 pooka
291 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
292 1.3 pooka
293 1.3 pooka # check if we we get what we wrote
294 1.6 pooka atf_check -s exit:0 -o file:testfile -e ignore \
295 1.6 pooka rump.dd if=${rawraid} count=4
296 1.3 pooka }
297 1.3 pooka
298 1.3 pooka raid5_compfail_cleanup()
299 1.3 pooka {
300 1.3 pooka export RUMP_SERVER=unix://sock
301 1.3 pooka rump.halt
302 1.3 pooka }
303 1.3 pooka
304 1.9 oster atf_test_case raid5_normal cleanup
305 1.9 oster raid5_normal_head()
306 1.9 oster {
307 1.9 oster atf_set "descr" "Checks that RAID5 works after normal shutdown " \
308 1.9 oster "and 'raidctl -c' startup"
309 1.12 joerg atf_set "require.progs" "rump_server"
310 1.9 oster }
311 1.9 oster
312 1.9 oster raid5_normal_body()
313 1.9 oster {
314 1.9 oster makecfg 5 3
315 1.9 oster export RUMP_SERVER=unix://sock
316 1.9 oster atf_check -s exit:0 ${raidserver} \
317 1.9 oster -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
318 1.9 oster -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
319 1.9 oster -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
320 1.9 oster ${RUMP_SERVER}
321 1.9 oster
322 1.9 oster atf_check -s exit:0 rump.raidctl -C raid.conf raid0
323 1.9 oster atf_check -s exit:0 rump.raidctl -I 12345 raid0
324 1.9 oster atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
325 1.9 oster
326 1.9 oster # put some data there
327 1.9 oster atf_check -s exit:0 -e ignore \
328 1.9 oster dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
329 1.9 oster atf_check -s exit:0 -e ignore -x \
330 1.9 oster "dd if=testfile | rump.dd of=${rawraid} conv=sync"
331 1.9 oster
332 1.9 oster # restart server after normal shutdown
333 1.9 oster rump.halt
334 1.9 oster
335 1.9 oster atf_check -s exit:0 ${raidserver} \
336 1.9 oster -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
337 1.9 oster -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
338 1.9 oster -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
339 1.9 oster ${RUMP_SERVER}
340 1.9 oster
341 1.9 oster atf_check -s exit:0 rump.raidctl -c raid.conf raid0
342 1.9 oster
343 1.9 oster # check if we we get what we wrote
344 1.9 oster atf_check -s exit:0 -o file:testfile -e ignore \
345 1.9 oster rump.dd if=${rawraid} count=4
346 1.9 oster }
347 1.9 oster
348 1.9 oster raid5_normal_cleanup()
349 1.9 oster {
350 1.9 oster export RUMP_SERVER=unix://sock
351 1.9 oster rump.halt
352 1.9 oster }
353 1.4 pooka
354 1.1 pooka atf_init_test_cases()
355 1.1 pooka {
356 1.1 pooka atf_add_test_case smalldisk
357 1.13 mrg atf_add_test_case old_numrows_config
358 1.9 oster atf_add_test_case raid1_normal
359 1.4 pooka atf_add_test_case raid1_comp0fail
360 1.3 pooka atf_add_test_case raid1_compfail
361 1.9 oster atf_add_test_case raid5_normal
362 1.3 pooka atf_add_test_case raid5_compfail
363 1.1 pooka }
364