Home | History | Annotate | Line # | Download | only in raidframe
t_raid.sh revision 1.5
      1 #	$NetBSD: t_raid.sh,v 1.5 2010/12/30 16:58:07 pooka Exp $
      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 
     28 rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'`
     29 rawraid=/dev/rraid0${rawpart}
     30 raidserver="rump_server -lrumpvfs -lrumpdev -lrumpdev_disk -lrumpdev_raidframe"
     31 
     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
     49 smalldisk_head()
     50 {
     51 	atf_set "descr" "Checks the raidframe works on small disks " \
     52 	    "(PR kern/44239)"
     53 }
     54 
     55 smalldisk_body()
     56 {
     57 	makecfg 1 2
     58 	export RUMP_SERVER=unix://sock
     59 	atf_check -s exit:0 ${raidserver}			\
     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 
     75 
     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
     89 	atf_check -s exit:0 ${raidserver}				\
     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
    101 	atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
    102 
    103 	# restart server with failed component
    104 	rump.halt
    105 	rm disk1.img # FAIL
    106 	atf_check -s exit:0 ${raidserver}				\
    107 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    108 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    109 	    ${RUMP_SERVER}
    110 
    111 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    112 
    113 	# check if we we get what we wrote
    114 	atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
    115 }
    116 
    117 raid1_compfail_cleanup()
    118 {
    119 	export RUMP_SERVER=unix://sock
    120 	rump.halt
    121 }
    122 
    123 
    124 
    125 atf_test_case raid1_comp0fail cleanup
    126 raid1_comp0fail_head()
    127 {
    128 	atf_set "descr" "Checks configuring RAID1 after component 0 fails"
    129 }
    130 
    131 raid1_comp0fail_body()
    132 {
    133 	makecfg 1 2
    134 	export RUMP_SERVER=unix://sock
    135 	atf_check -s exit:0 ${raidserver}				\
    136 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    137 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    138 	    ${RUMP_SERVER}
    139 
    140 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    141 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    142 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    143 
    144 	# restart server with failed component
    145 	rump.halt
    146 	rm disk0.img # FAIL
    147 	atf_check -s exit:0 ${raidserver}				\
    148 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    149 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    150 	    ${RUMP_SERVER}
    151 
    152 	atf_expect_fail "PR kern/44251"
    153 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    154 }
    155 
    156 raid1_comp0fail_cleanup()
    157 {
    158 	export RUMP_SERVER=unix://sock
    159 	rump.halt
    160 }
    161 
    162 
    163 atf_test_case raid5_compfail cleanup
    164 raid5_compfail_head()
    165 {
    166 	atf_set "descr" "Checks that RAID5 works after component failure"
    167 }
    168 
    169 raid5_compfail_body()
    170 {
    171 	makecfg 5 3
    172 	export RUMP_SERVER=unix://sock
    173 	atf_check -s exit:0 ${raidserver}				\
    174 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    175 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    176 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    177 	    ${RUMP_SERVER}
    178 
    179 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    180 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    181 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    182 
    183 	# put some data there
    184 	atf_check -s exit:0 -e ignore \
    185 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    186 	atf_check -s exit:0 -e ignore dd if=testfile rof=${rawraid} conv=sync
    187 
    188 	# restart server with failed component
    189 	rump.halt
    190 	rm disk2.img # FAIL
    191 	atf_check -s exit:0 ${raidserver}				\
    192 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    193 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    194 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    195 	    ${RUMP_SERVER}
    196 
    197 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    198 
    199 	# check if we we get what we wrote
    200 	atf_check -s exit:0 -o file:testfile -e ignore dd rif=${rawraid} count=4
    201 }
    202 
    203 raid5_compfail_cleanup()
    204 {
    205 	export RUMP_SERVER=unix://sock
    206 	rump.halt
    207 }
    208 
    209 
    210 atf_init_test_cases()
    211 {
    212 	atf_add_test_case smalldisk
    213 	atf_add_test_case raid1_comp0fail
    214 	atf_add_test_case raid1_compfail
    215 	atf_add_test_case raid5_compfail
    216 }
    217