t_raid.sh revision 1.3 1 1.3 pooka # $NetBSD: t_raid.sh,v 1.3 2010/12/18 09:26:57 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.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
58 1.1 pooka makecfg 1 2
59 1.1 pooka export RUMP_SERVER=unix://sock
60 1.1 pooka atf_check -s exit:0 rump_allserver \
61 1.1 pooka -d key=/disk0,hostpath=disk0.img,size=1m \
62 1.1 pooka -d key=/disk1,hostpath=disk1.img,size=1m \
63 1.1 pooka ${RUMP_SERVER}
64 1.1 pooka
65 1.1 pooka atf_expect_fail "PR kern/44239" # ADJUST CLEANUP WHEN THIS IS FIXED!
66 1.1 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
67 1.1 pooka }
68 1.1 pooka
69 1.1 pooka smalldisk_cleanup()
70 1.1 pooka {
71 1.1 pooka
72 1.1 pooka export RUMP_SERVER=unix://sock
73 1.1 pooka rump.halt
74 1.1 pooka : server dumps currently, so reset error. remove this line when fixed
75 1.1 pooka }
76 1.1 pooka
77 1.3 pooka # make this smaller once 44239 is fixed
78 1.3 pooka export RAID_MEDIASIZE=32m
79 1.3 pooka
80 1.3 pooka atf_test_case raid1_compfail cleanup
81 1.3 pooka raid1_compfail_head()
82 1.3 pooka {
83 1.3 pooka
84 1.3 pooka atf_set "descr" "Checks that RAID1 works after component failure"
85 1.3 pooka }
86 1.3 pooka
87 1.3 pooka raid1_compfail_body()
88 1.3 pooka {
89 1.3 pooka
90 1.3 pooka makecfg 1 2
91 1.3 pooka export RUMP_SERVER=unix://sock
92 1.3 pooka atf_check -s exit:0 rump_allserver \
93 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
94 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
95 1.3 pooka ${RUMP_SERVER}
96 1.3 pooka
97 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
98 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
99 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
100 1.3 pooka
101 1.3 pooka # put some data there
102 1.3 pooka atf_check -s exit:0 -e ignore \
103 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
104 1.3 pooka atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
105 1.3 pooka
106 1.3 pooka # restart server with failed component
107 1.3 pooka rump.halt
108 1.3 pooka rm disk1.img # FAIL
109 1.3 pooka atf_check -s exit:0 rump_allserver \
110 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
111 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
112 1.3 pooka ${RUMP_SERVER}
113 1.3 pooka
114 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
115 1.3 pooka
116 1.3 pooka # check if we we get what we wrote
117 1.3 pooka atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
118 1.3 pooka }
119 1.3 pooka
120 1.3 pooka raid1_compfail_cleanup()
121 1.3 pooka {
122 1.3 pooka
123 1.3 pooka export RUMP_SERVER=unix://sock
124 1.3 pooka rump.halt
125 1.3 pooka }
126 1.3 pooka
127 1.3 pooka atf_test_case raid5_compfail cleanup
128 1.3 pooka raid5_compfail_head()
129 1.3 pooka {
130 1.3 pooka
131 1.3 pooka atf_set "descr" "Checks that RAID5 works after component failure"
132 1.3 pooka }
133 1.3 pooka
134 1.3 pooka raid5_compfail_body()
135 1.3 pooka {
136 1.3 pooka
137 1.3 pooka makecfg 5 3
138 1.3 pooka export RUMP_SERVER=unix://sock
139 1.3 pooka atf_check -s exit:0 rump_allserver \
140 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
141 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
142 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
143 1.3 pooka ${RUMP_SERVER}
144 1.3 pooka
145 1.3 pooka atf_check -s exit:0 rump.raidctl -C raid.conf raid0
146 1.3 pooka atf_check -s exit:0 rump.raidctl -I 12345 raid0
147 1.3 pooka atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
148 1.3 pooka
149 1.3 pooka # put some data there
150 1.3 pooka atf_check -s exit:0 -e ignore \
151 1.3 pooka dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
152 1.3 pooka atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
153 1.3 pooka
154 1.3 pooka # restart server with failed component
155 1.3 pooka rump.halt
156 1.3 pooka rm disk2.img # FAIL
157 1.3 pooka atf_check -s exit:0 rump_allserver \
158 1.3 pooka -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \
159 1.3 pooka -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \
160 1.3 pooka -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \
161 1.3 pooka ${RUMP_SERVER}
162 1.3 pooka
163 1.3 pooka atf_check -s exit:0 rump.raidctl -c raid.conf raid0
164 1.3 pooka
165 1.3 pooka # check if we we get what we wrote
166 1.3 pooka atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
167 1.3 pooka }
168 1.3 pooka
169 1.3 pooka raid5_compfail_cleanup()
170 1.3 pooka {
171 1.3 pooka
172 1.3 pooka export RUMP_SERVER=unix://sock
173 1.3 pooka rump.halt
174 1.3 pooka }
175 1.3 pooka
176 1.1 pooka atf_init_test_cases()
177 1.1 pooka {
178 1.1 pooka
179 1.1 pooka atf_add_test_case smalldisk
180 1.3 pooka atf_add_test_case raid1_compfail
181 1.3 pooka atf_add_test_case raid5_compfail
182 1.1 pooka }
183