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