2 # $NetBSD: t_raid.sh,v 1.12 2013/02/19 21:08:24 joerg Exp $
4 # Copyright (c) 2010 The NetBSD Foundation, Inc.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
29 rawpart
=`sysctl -n kern.rawpartition | tr '01234' 'abcde'`
30 rawraid
=/dev
/rraid0
${rawpart}
31 raidserver
="rump_server -lrumpvfs -lrumpdev -lrumpdev_disk -lrumpdev_raidframe"
38 printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf
40 while [ ${ncol} -gt ${diskn} ] ; do
41 echo "/disk${diskn}" >> raid.conf
45 printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
49 atf_test_case smalldisk cleanup
52 atf_set
"descr" "Checks the raidframe works on small disks " \
54 atf_set
"require.progs" "rump_server"
60 export RUMP_SERVER
=unix
://sock
61 atf_check
-s exit:0 ${raidserver} \
62 -d key
=/disk0
,hostpath
=disk0.img
,size
=1m \
63 -d key
=/disk1
,hostpath
=disk1.img
,size
=1m \
66 atf_check
-s exit:0 rump.raidctl
-C raid.conf raid0
71 export RUMP_SERVER
=unix
://sock
76 # make this smaller once 44239 is fixed
77 export RAID_MEDIASIZE
=32m
79 atf_test_case raid1_compfail cleanup
82 atf_set
"descr" "Checks that RAID1 works after component failure"
83 atf_set
"require.progs" "rump_server"
89 export RUMP_SERVER
=unix
://sock
90 atf_check
-s exit:0 ${raidserver} \
91 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
92 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
95 atf_check
-s exit:0 rump.raidctl
-C raid.conf raid0
96 atf_check
-s exit:0 rump.raidctl
-I 12345 raid0
97 atf_check
-s exit:0 -o ignore rump.raidctl
-iv raid0
100 atf_check
-s exit:0 -e ignore \
101 dd if=$
(atf_get_srcdir
)/t_raid of
=testfile count
=4
102 atf_check
-s exit:0 -e ignore
-x \
103 "dd if=testfile | rump.dd of=${rawraid} conv=sync"
105 # restart server with failed component
108 atf_check
-s exit:0 ${raidserver} \
109 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
110 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
113 atf_check
-s exit:0 rump.raidctl
-c raid.conf raid0
115 # check if we we get what we wrote
116 atf_check
-s exit:0 -o file:testfile
-e ignore \
117 rump.
dd if=${rawraid} count
=4
120 raid1_compfail_cleanup
()
122 export RUMP_SERVER
=unix
://sock
128 atf_test_case raid1_comp0fail cleanup
129 raid1_comp0fail_head
()
131 atf_set
"descr" "Checks configuring RAID1 after component 0 fails" \
133 atf_set
"require.progs" "rump_server"
136 raid1_comp0fail_body
()
139 export RUMP_SERVER
=unix
://sock
140 atf_check
-s exit:0 ${raidserver} \
141 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
142 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
145 atf_check
-s exit:0 rump.raidctl
-C raid.conf raid0
146 atf_check
-s exit:0 rump.raidctl
-I 12345 raid0
147 atf_check
-s exit:0 -o ignore rump.raidctl
-iv raid0
149 # restart server with failed component
152 atf_check
-s exit:0 ${raidserver} \
153 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
154 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
157 atf_check
-s exit:0 rump.raidctl
-c raid.conf raid0
160 raid1_comp0fail_cleanup
()
162 export RUMP_SERVER
=unix
://sock
166 atf_test_case raid1_normal cleanup
169 atf_set
"descr" "Checks that RAID1 -c configurations work " \
171 atf_set
"require.progs" "rump_server"
177 export RUMP_SERVER
=unix
://sock
178 atf_check
-s exit:0 ${raidserver} \
179 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
180 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
183 atf_check
-s exit:0 rump.raidctl
-C raid.conf raid0
184 atf_check
-s exit:0 rump.raidctl
-I 12345 raid0
185 atf_check
-s exit:0 -o ignore rump.raidctl
-iv raid0
187 # put some data there
188 atf_check
-s exit:0 -e ignore \
189 dd if=$
(atf_get_srcdir
)/t_raid of
=testfile count
=4
190 atf_check
-s exit:0 -e ignore
-x \
191 "dd if=testfile | rump.dd of=${rawraid} conv=sync"
193 # restart server, disks remain normal
196 atf_check
-s exit:0 ${raidserver} \
197 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
198 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
201 atf_check
-s exit:0 rump.raidctl
-c raid.conf raid0
203 # check if we we get what we wrote
204 atf_check
-s exit:0 -o file:testfile
-e ignore \
205 rump.
dd if=${rawraid} count
=4
209 raid1_normal_cleanup
()
211 export RUMP_SERVER
=unix
://sock
216 atf_test_case raid5_compfail cleanup
217 raid5_compfail_head
()
219 atf_set
"descr" "Checks that RAID5 works after component failure"
220 atf_set
"require.progs" "rump_server"
223 raid5_compfail_body
()
226 export RUMP_SERVER
=unix
://sock
227 atf_check
-s exit:0 ${raidserver} \
228 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
229 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
230 -d key
=/disk2
,hostpath
=disk2.img
,size
=${RAID_MEDIASIZE} \
233 atf_check
-s exit:0 rump.raidctl
-C raid.conf raid0
234 atf_check
-s exit:0 rump.raidctl
-I 12345 raid0
235 atf_check
-s exit:0 -o ignore rump.raidctl
-iv raid0
237 # put some data there
238 atf_check
-s exit:0 -e ignore \
239 dd if=$
(atf_get_srcdir
)/t_raid of
=testfile count
=4
240 atf_check
-s exit:0 -e ignore
-x \
241 "dd if=testfile | rump.dd of=${rawraid} conv=sync"
243 # restart server with failed component
246 atf_check
-s exit:0 ${raidserver} \
247 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
248 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
249 -d key
=/disk2
,hostpath
=disk2.img
,size
=${RAID_MEDIASIZE} \
252 atf_check
-s exit:0 rump.raidctl
-c raid.conf raid0
254 # check if we we get what we wrote
255 atf_check
-s exit:0 -o file:testfile
-e ignore \
256 rump.
dd if=${rawraid} count
=4
259 raid5_compfail_cleanup
()
261 export RUMP_SERVER
=unix
://sock
265 atf_test_case raid5_normal cleanup
268 atf_set
"descr" "Checks that RAID5 works after normal shutdown " \
269 "and 'raidctl -c' startup"
270 atf_set
"require.progs" "rump_server"
276 export RUMP_SERVER
=unix
://sock
277 atf_check
-s exit:0 ${raidserver} \
278 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
279 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
280 -d key
=/disk2
,hostpath
=disk2.img
,size
=${RAID_MEDIASIZE} \
283 atf_check
-s exit:0 rump.raidctl
-C raid.conf raid0
284 atf_check
-s exit:0 rump.raidctl
-I 12345 raid0
285 atf_check
-s exit:0 -o ignore rump.raidctl
-iv raid0
287 # put some data there
288 atf_check
-s exit:0 -e ignore \
289 dd if=$
(atf_get_srcdir
)/t_raid of
=testfile count
=4
290 atf_check
-s exit:0 -e ignore
-x \
291 "dd if=testfile | rump.dd of=${rawraid} conv=sync"
293 # restart server after normal shutdown
296 atf_check
-s exit:0 ${raidserver} \
297 -d key
=/disk0
,hostpath
=disk0.img
,size
=${RAID_MEDIASIZE} \
298 -d key
=/disk1
,hostpath
=disk1.img
,size
=${RAID_MEDIASIZE} \
299 -d key
=/disk2
,hostpath
=disk2.img
,size
=${RAID_MEDIASIZE} \
302 atf_check
-s exit:0 rump.raidctl
-c raid.conf raid0
304 # check if we we get what we wrote
305 atf_check
-s exit:0 -o file:testfile
-e ignore \
306 rump.
dd if=${rawraid} count
=4
309 raid5_normal_cleanup
()
311 export RUMP_SERVER
=unix
://sock
315 atf_init_test_cases
()
317 atf_add_test_case smalldisk
318 atf_add_test_case raid1_normal
319 atf_add_test_case raid1_comp0fail
320 atf_add_test_case raid1_compfail
321 atf_add_test_case raid5_normal
322 atf_add_test_case raid5_compfail