Home | History | Annotate | Line # | Download | only in raidframe
t_raid.sh revision 1.5.2.1
      1  1.5.2.1  bouyer #	$NetBSD: t_raid.sh,v 1.5.2.1 2011/02/08 16:20:09 bouyer 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.5.2.1  bouyer 	atf_check -s exit:0 -e ignore sh -c \
    102  1.5.2.1  bouyer 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    103      1.3   pooka 
    104      1.3   pooka 	# restart server with failed component
    105      1.3   pooka 	rump.halt
    106      1.3   pooka 	rm disk1.img # FAIL
    107      1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    108      1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    109      1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    110      1.3   pooka 	    ${RUMP_SERVER}
    111      1.3   pooka 
    112      1.3   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    113      1.3   pooka 
    114      1.3   pooka 	# check if we we get what we wrote
    115  1.5.2.1  bouyer 	atf_check -s exit:0 -o file:testfile -e ignore \
    116  1.5.2.1  bouyer 	    rump.dd if=${rawraid} count=4
    117      1.3   pooka }
    118      1.3   pooka 
    119      1.3   pooka raid1_compfail_cleanup()
    120      1.3   pooka {
    121      1.4   pooka 	export RUMP_SERVER=unix://sock
    122      1.4   pooka 	rump.halt
    123      1.4   pooka }
    124      1.4   pooka 
    125      1.4   pooka 
    126      1.4   pooka 
    127      1.4   pooka atf_test_case raid1_comp0fail cleanup
    128      1.4   pooka raid1_comp0fail_head()
    129      1.4   pooka {
    130      1.4   pooka 	atf_set "descr" "Checks configuring RAID1 after component 0 fails"
    131      1.4   pooka }
    132      1.3   pooka 
    133      1.4   pooka raid1_comp0fail_body()
    134      1.4   pooka {
    135      1.4   pooka 	makecfg 1 2
    136      1.3   pooka 	export RUMP_SERVER=unix://sock
    137      1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    138      1.4   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    139      1.4   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    140      1.4   pooka 	    ${RUMP_SERVER}
    141      1.4   pooka 
    142      1.4   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    143      1.4   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    144      1.4   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    145      1.4   pooka 
    146      1.4   pooka 	# restart server with failed component
    147      1.3   pooka 	rump.halt
    148      1.4   pooka 	rm disk0.img # FAIL
    149      1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    150      1.4   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    151      1.4   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    152      1.4   pooka 	    ${RUMP_SERVER}
    153      1.4   pooka 
    154      1.4   pooka 	atf_expect_fail "PR kern/44251"
    155      1.4   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    156      1.3   pooka }
    157      1.3   pooka 
    158      1.4   pooka raid1_comp0fail_cleanup()
    159      1.4   pooka {
    160      1.4   pooka 	export RUMP_SERVER=unix://sock
    161      1.4   pooka 	rump.halt
    162      1.4   pooka }
    163      1.4   pooka 
    164      1.4   pooka 
    165      1.3   pooka atf_test_case raid5_compfail cleanup
    166      1.3   pooka raid5_compfail_head()
    167      1.3   pooka {
    168      1.3   pooka 	atf_set "descr" "Checks that RAID5 works after component failure"
    169      1.3   pooka }
    170      1.3   pooka 
    171      1.3   pooka raid5_compfail_body()
    172      1.3   pooka {
    173      1.3   pooka 	makecfg 5 3
    174      1.3   pooka 	export RUMP_SERVER=unix://sock
    175      1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    176      1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    177      1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    178      1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    179      1.3   pooka 	    ${RUMP_SERVER}
    180      1.3   pooka 
    181      1.3   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    182      1.3   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    183      1.3   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    184      1.3   pooka 
    185      1.3   pooka 	# put some data there
    186      1.3   pooka 	atf_check -s exit:0 -e ignore \
    187      1.3   pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    188  1.5.2.1  bouyer 	atf_check -s exit:0 -e ignore sh -c \
    189  1.5.2.1  bouyer 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    190      1.3   pooka 
    191      1.3   pooka 	# restart server with failed component
    192      1.3   pooka 	rump.halt
    193      1.3   pooka 	rm disk2.img # FAIL
    194      1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    195      1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    196      1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    197      1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    198      1.3   pooka 	    ${RUMP_SERVER}
    199      1.3   pooka 
    200      1.3   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    201      1.3   pooka 
    202      1.3   pooka 	# check if we we get what we wrote
    203  1.5.2.1  bouyer 	atf_check -s exit:0 -o file:testfile -e ignore \
    204  1.5.2.1  bouyer 	    rump.dd if=${rawraid} count=4
    205      1.3   pooka }
    206      1.3   pooka 
    207      1.3   pooka raid5_compfail_cleanup()
    208      1.3   pooka {
    209      1.3   pooka 	export RUMP_SERVER=unix://sock
    210      1.3   pooka 	rump.halt
    211      1.3   pooka }
    212      1.3   pooka 
    213      1.4   pooka 
    214      1.1   pooka atf_init_test_cases()
    215      1.1   pooka {
    216      1.1   pooka 	atf_add_test_case smalldisk
    217      1.4   pooka 	atf_add_test_case raid1_comp0fail
    218      1.3   pooka 	atf_add_test_case raid1_compfail
    219      1.3   pooka 	atf_add_test_case raid5_compfail
    220      1.1   pooka }
    221