Home | History | Annotate | Line # | Download | only in raidframe
t_raid.sh revision 1.9
      1  1.9  oster #! /usr/bin/atf-sh
      2  1.9  oster #	$NetBSD: t_raid.sh,v 1.9 2011/07/29 19:57:38 oster Exp $
      3  1.1  pooka #
      4  1.1  pooka # Copyright (c) 2010 The NetBSD Foundation, Inc.
      5  1.1  pooka # All rights reserved.
      6  1.1  pooka #
      7  1.1  pooka # Redistribution and use in source and binary forms, with or without
      8  1.1  pooka # modification, are permitted provided that the following conditions
      9  1.1  pooka # are met:
     10  1.1  pooka # 1. Redistributions of source code must retain the above copyright
     11  1.1  pooka #    notice, this list of conditions and the following disclaimer.
     12  1.1  pooka # 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  pooka #    notice, this list of conditions and the following disclaimer in the
     14  1.1  pooka #    documentation and/or other materials provided with the distribution.
     15  1.1  pooka #
     16  1.1  pooka # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.1  pooka # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.1  pooka # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.1  pooka # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.1  pooka # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1  pooka # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1  pooka # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1  pooka # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1  pooka # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1  pooka # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  pooka # POSSIBILITY OF SUCH DAMAGE.
     27  1.1  pooka #
     28  1.1  pooka 
     29  1.3  pooka rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'`
     30  1.3  pooka rawraid=/dev/rraid0${rawpart}
     31  1.5  pooka raidserver="rump_server -lrumpvfs -lrumpdev -lrumpdev_disk -lrumpdev_raidframe"
     32  1.3  pooka 
     33  1.1  pooka makecfg()
     34  1.1  pooka {
     35  1.1  pooka 	level=${1}
     36  1.1  pooka 	ncol=${2}
     37  1.1  pooka 
     38  1.1  pooka 	printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf
     39  1.1  pooka 	diskn=0
     40  1.1  pooka 	while [ ${ncol} -gt ${diskn} ] ; do
     41  1.1  pooka 		echo "/disk${diskn}" >> raid.conf
     42  1.1  pooka 		diskn=$((diskn+1))
     43  1.1  pooka 	done
     44  1.1  pooka 
     45  1.1  pooka 	printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
     46  1.1  pooka 	    >> raid.conf
     47  1.1  pooka }
     48  1.1  pooka 
     49  1.1  pooka atf_test_case smalldisk cleanup
     50  1.2  pooka smalldisk_head()
     51  1.1  pooka {
     52  1.3  pooka 	atf_set "descr" "Checks the raidframe works on small disks " \
     53  1.3  pooka 	    "(PR kern/44239)"
     54  1.1  pooka }
     55  1.1  pooka 
     56  1.1  pooka smalldisk_body()
     57  1.1  pooka {
     58  1.1  pooka 	makecfg 1 2
     59  1.1  pooka 	export RUMP_SERVER=unix://sock
     60  1.5  pooka 	atf_check -s exit:0 ${raidserver}			\
     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_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 }
     73  1.1  pooka 
     74  1.4  pooka 
     75  1.3  pooka # make this smaller once 44239 is fixed
     76  1.3  pooka export RAID_MEDIASIZE=32m
     77  1.3  pooka 
     78  1.3  pooka atf_test_case raid1_compfail cleanup
     79  1.3  pooka raid1_compfail_head()
     80  1.3  pooka {
     81  1.3  pooka 	atf_set "descr" "Checks that RAID1 works after component failure"
     82  1.3  pooka }
     83  1.3  pooka 
     84  1.3  pooka raid1_compfail_body()
     85  1.3  pooka {
     86  1.3  pooka 	makecfg 1 2
     87  1.3  pooka 	export RUMP_SERVER=unix://sock
     88  1.5  pooka 	atf_check -s exit:0 ${raidserver}				\
     89  1.3  pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
     90  1.3  pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
     91  1.3  pooka 	    ${RUMP_SERVER}
     92  1.3  pooka 
     93  1.3  pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
     94  1.3  pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
     95  1.3  pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
     96  1.3  pooka 
     97  1.3  pooka 	# put some data there
     98  1.3  pooka 	atf_check -s exit:0 -e ignore \
     99  1.3  pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    100  1.8   jmmv 	atf_check -s exit:0 -e ignore -x \
    101  1.6  pooka 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    102  1.3  pooka 
    103  1.3  pooka 	# restart server with failed component
    104  1.3  pooka 	rump.halt
    105  1.3  pooka 	rm disk1.img # FAIL
    106  1.5  pooka 	atf_check -s exit:0 ${raidserver}				\
    107  1.3  pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    108  1.3  pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    109  1.3  pooka 	    ${RUMP_SERVER}
    110  1.3  pooka 
    111  1.3  pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    112  1.3  pooka 
    113  1.3  pooka 	# check if we we get what we wrote
    114  1.6  pooka 	atf_check -s exit:0 -o file:testfile -e ignore \
    115  1.6  pooka 	    rump.dd if=${rawraid} count=4
    116  1.3  pooka }
    117  1.3  pooka 
    118  1.3  pooka raid1_compfail_cleanup()
    119  1.3  pooka {
    120  1.4  pooka 	export RUMP_SERVER=unix://sock
    121  1.4  pooka 	rump.halt
    122  1.4  pooka }
    123  1.4  pooka 
    124  1.4  pooka 
    125  1.4  pooka 
    126  1.4  pooka atf_test_case raid1_comp0fail cleanup
    127  1.4  pooka raid1_comp0fail_head()
    128  1.4  pooka {
    129  1.9  oster 	atf_set "descr" "Checks configuring RAID1 after component 0 fails" \
    130  1.9  oster 		"(PR kern/44251)"
    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.9  oster 	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_check -s exit:0 rump.raidctl -c raid.conf raid0
    155  1.3  pooka }
    156  1.3  pooka 
    157  1.4  pooka raid1_comp0fail_cleanup()
    158  1.4  pooka {
    159  1.4  pooka 	export RUMP_SERVER=unix://sock
    160  1.4  pooka 	rump.halt
    161  1.4  pooka }
    162  1.4  pooka 
    163  1.9  oster atf_test_case raid1_normal cleanup
    164  1.9  oster raid1_normal_head()
    165  1.9  oster {
    166  1.9  oster 	atf_set "descr" "Checks that RAID1 -c configurations work " \
    167  1.9  oster 		"in the normal case"
    168  1.9  oster }
    169  1.9  oster 
    170  1.9  oster raid1_normal_body()
    171  1.9  oster {
    172  1.9  oster 	makecfg 1 2
    173  1.9  oster         atf_check -s exit:0 ${raidserver}                               \
    174  1.9  oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    175  1.9  oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    176  1.9  oster             ${RUMP_SERVER}
    177  1.9  oster 
    178  1.9  oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    179  1.9  oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    180  1.9  oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    181  1.9  oster 
    182  1.9  oster         # put some data there
    183  1.9  oster         atf_check -s exit:0 -e ignore \
    184  1.9  oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    185  1.9  oster         atf_check -s exit:0 -e ignore -x \
    186  1.9  oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    187  1.9  oster 
    188  1.9  oster         # restart server, disks remain normal 
    189  1.9  oster         rump.halt
    190  1.9  oster 
    191  1.9  oster         atf_check -s exit:0 ${raidserver}                               \
    192  1.9  oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    193  1.9  oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    194  1.9  oster             ${RUMP_SERVER}
    195  1.9  oster 
    196  1.9  oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    197  1.9  oster 
    198  1.9  oster         # check if we we get what we wrote
    199  1.9  oster         atf_check -s exit:0 -o file:testfile -e ignore \
    200  1.9  oster             rump.dd if=${rawraid} count=4
    201  1.9  oster 
    202  1.9  oster }
    203  1.9  oster 
    204  1.9  oster raid1_comp0fail_cleanup()
    205  1.9  oster {       
    206  1.9  oster         export RUMP_SERVER=unix://sock
    207  1.9  oster         rump.halt
    208  1.9  oster }
    209  1.9  oster 
    210  1.4  pooka 
    211  1.3  pooka atf_test_case raid5_compfail cleanup
    212  1.3  pooka raid5_compfail_head()
    213  1.3  pooka {
    214  1.3  pooka 	atf_set "descr" "Checks that RAID5 works after component failure"
    215  1.3  pooka }
    216  1.3  pooka 
    217  1.3  pooka raid5_compfail_body()
    218  1.3  pooka {
    219  1.3  pooka 	makecfg 5 3
    220  1.3  pooka 	export RUMP_SERVER=unix://sock
    221  1.5  pooka 	atf_check -s exit:0 ${raidserver}				\
    222  1.3  pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    223  1.3  pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    224  1.3  pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    225  1.3  pooka 	    ${RUMP_SERVER}
    226  1.3  pooka 
    227  1.3  pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    228  1.3  pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    229  1.3  pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    230  1.3  pooka 
    231  1.3  pooka 	# put some data there
    232  1.3  pooka 	atf_check -s exit:0 -e ignore \
    233  1.3  pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    234  1.8   jmmv 	atf_check -s exit:0 -e ignore -x \
    235  1.6  pooka 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    236  1.3  pooka 
    237  1.3  pooka 	# restart server with failed component
    238  1.3  pooka 	rump.halt
    239  1.3  pooka 	rm disk2.img # FAIL
    240  1.5  pooka 	atf_check -s exit:0 ${raidserver}				\
    241  1.3  pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    242  1.3  pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    243  1.3  pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    244  1.3  pooka 	    ${RUMP_SERVER}
    245  1.3  pooka 
    246  1.3  pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    247  1.3  pooka 
    248  1.3  pooka 	# check if we we get what we wrote
    249  1.6  pooka 	atf_check -s exit:0 -o file:testfile -e ignore \
    250  1.6  pooka 	    rump.dd if=${rawraid} count=4
    251  1.3  pooka }
    252  1.3  pooka 
    253  1.3  pooka raid5_compfail_cleanup()
    254  1.3  pooka {
    255  1.3  pooka 	export RUMP_SERVER=unix://sock
    256  1.3  pooka 	rump.halt
    257  1.3  pooka }
    258  1.3  pooka 
    259  1.9  oster atf_test_case raid5_normal cleanup
    260  1.9  oster raid5_normal_head()
    261  1.9  oster {
    262  1.9  oster         atf_set "descr" "Checks that RAID5 works after normal shutdown " \
    263  1.9  oster 		"and 'raidctl -c' startup"
    264  1.9  oster }
    265  1.9  oster 
    266  1.9  oster raid5_normal_body()
    267  1.9  oster {
    268  1.9  oster         makecfg 5 3
    269  1.9  oster         export RUMP_SERVER=unix://sock
    270  1.9  oster         atf_check -s exit:0 ${raidserver}                               \
    271  1.9  oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    272  1.9  oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    273  1.9  oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    274  1.9  oster             ${RUMP_SERVER}
    275  1.9  oster 
    276  1.9  oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    277  1.9  oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    278  1.9  oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    279  1.9  oster 
    280  1.9  oster         # put some data there
    281  1.9  oster         atf_check -s exit:0 -e ignore \
    282  1.9  oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    283  1.9  oster         atf_check -s exit:0 -e ignore -x \
    284  1.9  oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    285  1.9  oster 
    286  1.9  oster         # restart server after normal shutdown
    287  1.9  oster         rump.halt
    288  1.9  oster 
    289  1.9  oster         atf_check -s exit:0 ${raidserver}                               \
    290  1.9  oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    291  1.9  oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    292  1.9  oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    293  1.9  oster             ${RUMP_SERVER}
    294  1.9  oster 
    295  1.9  oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    296  1.9  oster 
    297  1.9  oster         # check if we we get what we wrote
    298  1.9  oster         atf_check -s exit:0 -o file:testfile -e ignore \
    299  1.9  oster             rump.dd if=${rawraid} count=4
    300  1.9  oster }
    301  1.9  oster 
    302  1.9  oster raid5_normal_cleanup()
    303  1.9  oster {
    304  1.9  oster         export RUMP_SERVER=unix://sock
    305  1.9  oster         rump.halt
    306  1.9  oster }
    307  1.4  pooka 
    308  1.1  pooka atf_init_test_cases()
    309  1.1  pooka {
    310  1.1  pooka 	atf_add_test_case smalldisk
    311  1.9  oster 	atf_add_test_case raid1_normal
    312  1.4  pooka 	atf_add_test_case raid1_comp0fail
    313  1.3  pooka 	atf_add_test_case raid1_compfail
    314  1.9  oster 	atf_add_test_case raid5_normal
    315  1.3  pooka 	atf_add_test_case raid5_compfail
    316  1.1  pooka }
    317