t_raid.sh revision 1.5 1 1.5 pooka # $NetBSD: t_raid.sh,v 1.5 2010/12/30 16:58:07 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.5 pooka raidserver="rump_server -lrumpvfs -lrumpdev -lrumpdev_disk -lrumpdev_raidframe"
31 1.3 pooka
32 1.1 pooka makecfg()
33 1.1 pooka {
34 1.1 pooka level=${1}
35 1.1 pooka ncol=${2}
36 1.1 pooka
37 1.1 pooka printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf
38 1.1 pooka diskn=0
39 1.1 pooka while [ ${ncol} -gt ${diskn} ] ; do
40 1.1 pooka echo "/disk${diskn}" >> raid.conf
41 1.1 pooka diskn=$((diskn+1))
42 1.1 pooka done
43 1.1 pooka
44 1.1 pooka printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
45 1.1 pooka >> raid.conf
46 1.1 pooka }
47 1.1 pooka
48 1.1 pooka atf_test_case smalldisk cleanup
49 1.2 pooka smalldisk_head()
50 1.1 pooka {
51 1.3 pooka atf_set "descr" "Checks the raidframe works on small disks " \
52 1.3 pooka "(PR kern/44239)"
53 1.1 pooka }
54 1.1 pooka
55 1.1 pooka smalldisk_body()
56 1.1 pooka {
57 1.1 pooka makecfg 1 2
58 1.1 pooka export RUMP_SERVER=unix://sock
59 1.5 pooka atf_check -s exit:0 ${raidserver} \
60 1.1 pooka -d key=/disk0,hostpath=disk0.img,size=1m \
61 1.1 pooka -d key=/disk1,hostpath=disk1.img,size=1m \
62 1.1 pooka ${RUMP_SERVER}
63 1.1 pooka
64 1.1 pooka atf_expect_fail "PR kern/44239" # ADJUST CLEANUP WHEN THIS IS FIXED!
65 1.1 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
66 1.1 pooka }
67 1.1 pooka
68 1.1 pooka smalldisk_cleanup()
69 1.1 pooka {
70 1.1 pooka export RUMP_SERVER=unix://sock
71 1.1 pooka rump.halt
72 1.1 pooka : server dumps currently, so reset error. remove this line when fixed
73 1.1 pooka }
74 1.1 pooka
75 1.4 pooka
76 1.3 pooka # make this smaller once 44239 is fixed
77 1.3 pooka export RAID_MEDIASIZE=32m
78 1.3 pooka
79 1.3 pooka atf_test_case raid1_compfail cleanup
80 1.3 pooka raid1_compfail_head()
81 1.3 pooka {
82 1.3 pooka atf_set "descr" "Checks that RAID1 works after component failure"
83 1.3 pooka }
84 1.3 pooka
85 1.3 pooka raid1_compfail_body()
86 1.3 pooka {
87 1.3 pooka makecfg 1 2
88 1.3 pooka export RUMP_SERVER=unix://sock
89 1.5 pooka atf_check -s exit:0 ${raidserver} \
90 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
91 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
92 1.3 pooka ${RUMP_SERVER}
93 1.3 pooka
94 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
95 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
96 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
97 1.3 pooka
98 1.3 pooka # put some data there
99 1.3 pooka atf_check -s exit:0 -e ignore \
100 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
101 1.3 pooka atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
102 1.3 pooka
103 1.3 pooka # restart server with failed component
104 1.3 pooka rump.halt
105 1.3 pooka rm disk1.img # FAIL
106 1.5 pooka atf_check -s exit:0 ${raidserver} \
107 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
108 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
109 1.3 pooka ${RUMP_SERVER}
110 1.3 pooka
111 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
112 1.3 pooka
113 1.3 pooka # check if we we get what we wrote
114 1.3 pooka atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
115 1.3 pooka }
116 1.3 pooka
117 1.3 pooka raid1_compfail_cleanup()
118 1.3 pooka {
119 1.4 pooka export RUMP_SERVER=unix://sock
120 1.4 pooka rump.halt
121 1.4 pooka }
122 1.4 pooka
123 1.4 pooka
124 1.4 pooka
125 1.4 pooka atf_test_case raid1_comp0fail cleanup
126 1.4 pooka raid1_comp0fail_head()
127 1.4 pooka {
128 1.4 pooka atf_set "descr" "Checks configuring RAID1 after component 0 fails"
129 1.4 pooka }
130 1.3 pooka
131 1.4 pooka raid1_comp0fail_body()
132 1.4 pooka {
133 1.4 pooka makecfg 1 2
134 1.3 pooka export RUMP_SERVER=unix://sock
135 1.5 pooka atf_check -s exit:0 ${raidserver} \
136 1.4 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
137 1.4 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
138 1.4 pooka ${RUMP_SERVER}
139 1.4 pooka
140 1.4 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
141 1.4 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
142 1.4 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
143 1.4 pooka
144 1.4 pooka # restart server with failed component
145 1.3 pooka rump.halt
146 1.4 pooka rm disk0.img # FAIL
147 1.5 pooka atf_check -s exit:0 ${raidserver} \
148 1.4 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
149 1.4 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
150 1.4 pooka ${RUMP_SERVER}
151 1.4 pooka
152 1.4 pooka atf_expect_fail "PR kern/44251"
153 1.4 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
154 1.3 pooka }
155 1.3 pooka
156 1.4 pooka raid1_comp0fail_cleanup()
157 1.4 pooka {
158 1.4 pooka export RUMP_SERVER=unix://sock
159 1.4 pooka rump.halt
160 1.4 pooka }
161 1.4 pooka
162 1.4 pooka
163 1.3 pooka atf_test_case raid5_compfail cleanup
164 1.3 pooka raid5_compfail_head()
165 1.3 pooka {
166 1.3 pooka atf_set "descr" "Checks that RAID5 works after component failure"
167 1.3 pooka }
168 1.3 pooka
169 1.3 pooka raid5_compfail_body()
170 1.3 pooka {
171 1.3 pooka makecfg 5 3
172 1.3 pooka export RUMP_SERVER=unix://sock
173 1.5 pooka atf_check -s exit:0 ${raidserver} \
174 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
175 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
176 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
177 1.3 pooka ${RUMP_SERVER}
178 1.3 pooka
179 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
180 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
181 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
182 1.3 pooka
183 1.3 pooka # put some data there
184 1.3 pooka atf_check -s exit:0 -e ignore \
185 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
186 1.3 pooka atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
187 1.3 pooka
188 1.3 pooka # restart server with failed component
189 1.3 pooka rump.halt
190 1.3 pooka rm disk2.img # FAIL
191 1.5 pooka atf_check -s exit:0 ${raidserver} \
192 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
193 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
194 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
195 1.3 pooka ${RUMP_SERVER}
196 1.3 pooka
197 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
198 1.3 pooka
199 1.3 pooka # check if we we get what we wrote
200 1.3 pooka atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
201 1.3 pooka }
202 1.3 pooka
203 1.3 pooka raid5_compfail_cleanup()
204 1.3 pooka {
205 1.3 pooka export RUMP_SERVER=unix://sock
206 1.3 pooka rump.halt
207 1.3 pooka }
208 1.3 pooka
209 1.4 pooka
210 1.1 pooka atf_init_test_cases()
211 1.1 pooka {
212 1.1 pooka atf_add_test_case smalldisk
213 1.4 pooka atf_add_test_case raid1_comp0fail
214 1.3 pooka atf_add_test_case raid1_compfail
215 1.3 pooka atf_add_test_case raid5_compfail
216 1.1 pooka }
217