Home | History | Annotate | Line # | Download | only in raidframe
t_raid.sh revision 1.10
      1   1.9   oster #! /usr/bin/atf-sh
      2  1.10  martin #	$NetBSD: t_raid.sh,v 1.10 2011/08/09 13:48:55 martin 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.10  martin 	export RUMP_SERVER=unix://sock
    174   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    175   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    176   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    177   1.9   oster             ${RUMP_SERVER}
    178   1.9   oster 
    179   1.9   oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    180   1.9   oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    181   1.9   oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    182   1.9   oster 
    183   1.9   oster         # put some data there
    184   1.9   oster         atf_check -s exit:0 -e ignore \
    185   1.9   oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    186   1.9   oster         atf_check -s exit:0 -e ignore -x \
    187   1.9   oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    188   1.9   oster 
    189   1.9   oster         # restart server, disks remain normal 
    190   1.9   oster         rump.halt
    191   1.9   oster 
    192   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    193   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    194   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    195   1.9   oster             ${RUMP_SERVER}
    196   1.9   oster 
    197   1.9   oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    198   1.9   oster 
    199   1.9   oster         # check if we we get what we wrote
    200   1.9   oster         atf_check -s exit:0 -o file:testfile -e ignore \
    201   1.9   oster             rump.dd if=${rawraid} count=4
    202   1.9   oster 
    203   1.9   oster }
    204   1.9   oster 
    205   1.9   oster raid1_comp0fail_cleanup()
    206   1.9   oster {       
    207   1.9   oster         export RUMP_SERVER=unix://sock
    208   1.9   oster         rump.halt
    209   1.9   oster }
    210   1.9   oster 
    211   1.4   pooka 
    212   1.3   pooka atf_test_case raid5_compfail cleanup
    213   1.3   pooka raid5_compfail_head()
    214   1.3   pooka {
    215   1.3   pooka 	atf_set "descr" "Checks that RAID5 works after component failure"
    216   1.3   pooka }
    217   1.3   pooka 
    218   1.3   pooka raid5_compfail_body()
    219   1.3   pooka {
    220   1.3   pooka 	makecfg 5 3
    221   1.3   pooka 	export RUMP_SERVER=unix://sock
    222   1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    223   1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    224   1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    225   1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    226   1.3   pooka 	    ${RUMP_SERVER}
    227   1.3   pooka 
    228   1.3   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    229   1.3   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    230   1.3   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    231   1.3   pooka 
    232   1.3   pooka 	# put some data there
    233   1.3   pooka 	atf_check -s exit:0 -e ignore \
    234   1.3   pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    235   1.8    jmmv 	atf_check -s exit:0 -e ignore -x \
    236   1.6   pooka 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    237   1.3   pooka 
    238   1.3   pooka 	# restart server with failed component
    239   1.3   pooka 	rump.halt
    240   1.3   pooka 	rm disk2.img # FAIL
    241   1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    242   1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    243   1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    244   1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    245   1.3   pooka 	    ${RUMP_SERVER}
    246   1.3   pooka 
    247   1.3   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    248   1.3   pooka 
    249   1.3   pooka 	# check if we we get what we wrote
    250   1.6   pooka 	atf_check -s exit:0 -o file:testfile -e ignore \
    251   1.6   pooka 	    rump.dd if=${rawraid} count=4
    252   1.3   pooka }
    253   1.3   pooka 
    254   1.3   pooka raid5_compfail_cleanup()
    255   1.3   pooka {
    256   1.3   pooka 	export RUMP_SERVER=unix://sock
    257   1.3   pooka 	rump.halt
    258   1.3   pooka }
    259   1.3   pooka 
    260   1.9   oster atf_test_case raid5_normal cleanup
    261   1.9   oster raid5_normal_head()
    262   1.9   oster {
    263   1.9   oster         atf_set "descr" "Checks that RAID5 works after normal shutdown " \
    264   1.9   oster 		"and 'raidctl -c' startup"
    265   1.9   oster }
    266   1.9   oster 
    267   1.9   oster raid5_normal_body()
    268   1.9   oster {
    269   1.9   oster         makecfg 5 3
    270   1.9   oster         export RUMP_SERVER=unix://sock
    271   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    272   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    273   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    274   1.9   oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    275   1.9   oster             ${RUMP_SERVER}
    276   1.9   oster 
    277   1.9   oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    278   1.9   oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    279   1.9   oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    280   1.9   oster 
    281   1.9   oster         # put some data there
    282   1.9   oster         atf_check -s exit:0 -e ignore \
    283   1.9   oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    284   1.9   oster         atf_check -s exit:0 -e ignore -x \
    285   1.9   oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    286   1.9   oster 
    287   1.9   oster         # restart server after normal shutdown
    288   1.9   oster         rump.halt
    289   1.9   oster 
    290   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    291   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    292   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    293   1.9   oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    294   1.9   oster             ${RUMP_SERVER}
    295   1.9   oster 
    296   1.9   oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    297   1.9   oster 
    298   1.9   oster         # check if we we get what we wrote
    299   1.9   oster         atf_check -s exit:0 -o file:testfile -e ignore \
    300   1.9   oster             rump.dd if=${rawraid} count=4
    301   1.9   oster }
    302   1.9   oster 
    303   1.9   oster raid5_normal_cleanup()
    304   1.9   oster {
    305   1.9   oster         export RUMP_SERVER=unix://sock
    306   1.9   oster         rump.halt
    307   1.9   oster }
    308   1.4   pooka 
    309   1.1   pooka atf_init_test_cases()
    310   1.1   pooka {
    311   1.1   pooka 	atf_add_test_case smalldisk
    312   1.9   oster 	atf_add_test_case raid1_normal
    313   1.4   pooka 	atf_add_test_case raid1_comp0fail
    314   1.3   pooka 	atf_add_test_case raid1_compfail
    315   1.9   oster 	atf_add_test_case raid5_normal
    316   1.3   pooka 	atf_add_test_case raid5_compfail
    317   1.1   pooka }
    318