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