Home | History | Annotate | Line # | Download | only in raidframe
t_raid.sh revision 1.13
      1   1.9   oster #! /usr/bin/atf-sh
      2  1.13     mrg #	$NetBSD: t_raid.sh,v 1.13 2018/01/18 00:32:49 mrg 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.13     mrg 	printf "START array\n${ncol} 0\nSTART disks\n" > raid.conf
     39  1.13     mrg 	diskn=0
     40  1.13     mrg 	while [ ${ncol} -gt ${diskn} ] ; do
     41  1.13     mrg 		echo "/disk${diskn}" >> raid.conf
     42  1.13     mrg 		diskn=$((diskn+1))
     43  1.13     mrg 	done
     44  1.13     mrg 
     45  1.13     mrg 	printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
     46  1.13     mrg 	    >> raid.conf
     47  1.13     mrg }
     48  1.13     mrg 
     49  1.13     mrg makecfg_old()
     50  1.13     mrg {
     51  1.13     mrg 	level=${1}
     52  1.13     mrg 	ncol=${2}
     53  1.13     mrg 
     54   1.1   pooka 	printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf
     55   1.1   pooka 	diskn=0
     56   1.1   pooka 	while [ ${ncol} -gt ${diskn} ] ; do
     57   1.1   pooka 		echo "/disk${diskn}" >> raid.conf
     58   1.1   pooka 		diskn=$((diskn+1))
     59   1.1   pooka 	done
     60   1.1   pooka 
     61   1.1   pooka 	printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
     62   1.1   pooka 	    >> raid.conf
     63   1.1   pooka }
     64   1.1   pooka 
     65   1.1   pooka atf_test_case smalldisk cleanup
     66   1.2   pooka smalldisk_head()
     67   1.1   pooka {
     68   1.3   pooka 	atf_set "descr" "Checks the raidframe works on small disks " \
     69   1.3   pooka 	    "(PR kern/44239)"
     70  1.12   joerg 	atf_set "require.progs" "rump_server"
     71   1.1   pooka }
     72   1.1   pooka 
     73  1.13     mrg smalldisk_body_backend()
     74   1.1   pooka {
     75   1.1   pooka 	export RUMP_SERVER=unix://sock
     76   1.5   pooka 	atf_check -s exit:0 ${raidserver}			\
     77   1.1   pooka 	    -d key=/disk0,hostpath=disk0.img,size=1m		\
     78   1.1   pooka 	    -d key=/disk1,hostpath=disk1.img,size=1m		\
     79   1.1   pooka 	    ${RUMP_SERVER}
     80   1.1   pooka 
     81   1.1   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
     82   1.1   pooka }
     83   1.1   pooka 
     84  1.13     mrg smalldisk_body()
     85  1.13     mrg {
     86  1.13     mrg 	makecfg 1 2
     87  1.13     mrg 	smalldisk_body_backend
     88  1.13     mrg }
     89  1.13     mrg 
     90   1.1   pooka smalldisk_cleanup()
     91   1.1   pooka {
     92   1.1   pooka 	export RUMP_SERVER=unix://sock
     93   1.1   pooka 	rump.halt
     94   1.1   pooka }
     95   1.1   pooka 
     96  1.13     mrg # The old configuration test case uses the smalldisk backend
     97  1.13     mrg atf_test_case old_numrows_config cleanup
     98  1.13     mrg old_numrows_config_head()
     99  1.13     mrg {
    100  1.13     mrg 	atf_set "descr" "Checks the old numRows configuration works"
    101  1.13     mrg 	atf_set "require.progs" "rump_server"
    102  1.13     mrg }
    103  1.13     mrg 
    104  1.13     mrg old_numrows_config_body()
    105  1.13     mrg {
    106  1.13     mrg 	makecfg_old 1 2
    107  1.13     mrg 	smalldisk_body_backend
    108  1.13     mrg }
    109  1.13     mrg 
    110  1.13     mrg old_numrows_config_cleanup()
    111  1.13     mrg {
    112  1.13     mrg 	export RUMP_SERVER=unix://sock
    113  1.13     mrg 	rump.halt
    114  1.13     mrg }
    115   1.4   pooka 
    116   1.3   pooka # make this smaller once 44239 is fixed
    117   1.3   pooka export RAID_MEDIASIZE=32m
    118   1.3   pooka 
    119   1.3   pooka atf_test_case raid1_compfail cleanup
    120   1.3   pooka raid1_compfail_head()
    121   1.3   pooka {
    122   1.3   pooka 	atf_set "descr" "Checks that RAID1 works after component failure"
    123  1.12   joerg 	atf_set "require.progs" "rump_server"
    124   1.3   pooka }
    125   1.3   pooka 
    126   1.3   pooka raid1_compfail_body()
    127   1.3   pooka {
    128   1.3   pooka 	makecfg 1 2
    129   1.3   pooka 	export RUMP_SERVER=unix://sock
    130   1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    131   1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    132   1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    133   1.3   pooka 	    ${RUMP_SERVER}
    134   1.3   pooka 
    135   1.3   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    136   1.3   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    137   1.3   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    138   1.3   pooka 
    139   1.3   pooka 	# put some data there
    140   1.3   pooka 	atf_check -s exit:0 -e ignore \
    141   1.3   pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    142   1.8    jmmv 	atf_check -s exit:0 -e ignore -x \
    143   1.6   pooka 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    144   1.3   pooka 
    145   1.3   pooka 	# restart server with failed component
    146   1.3   pooka 	rump.halt
    147   1.3   pooka 	rm disk1.img # FAIL
    148   1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    149   1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    150   1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    151   1.3   pooka 	    ${RUMP_SERVER}
    152   1.3   pooka 
    153   1.3   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    154   1.3   pooka 
    155   1.3   pooka 	# check if we we get what we wrote
    156   1.6   pooka 	atf_check -s exit:0 -o file:testfile -e ignore \
    157   1.6   pooka 	    rump.dd if=${rawraid} count=4
    158   1.3   pooka }
    159   1.3   pooka 
    160   1.3   pooka raid1_compfail_cleanup()
    161   1.3   pooka {
    162   1.4   pooka 	export RUMP_SERVER=unix://sock
    163   1.4   pooka 	rump.halt
    164   1.4   pooka }
    165   1.4   pooka 
    166   1.4   pooka 
    167   1.4   pooka 
    168   1.4   pooka atf_test_case raid1_comp0fail cleanup
    169   1.4   pooka raid1_comp0fail_head()
    170   1.4   pooka {
    171   1.9   oster 	atf_set "descr" "Checks configuring RAID1 after component 0 fails" \
    172   1.9   oster 		"(PR kern/44251)"
    173  1.12   joerg 	atf_set "require.progs" "rump_server"
    174   1.4   pooka }
    175   1.3   pooka 
    176   1.4   pooka raid1_comp0fail_body()
    177   1.4   pooka {
    178   1.4   pooka 	makecfg 1 2
    179   1.3   pooka 	export RUMP_SERVER=unix://sock
    180   1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    181   1.4   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    182   1.4   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    183   1.4   pooka 	    ${RUMP_SERVER}
    184   1.4   pooka 
    185   1.4   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    186   1.4   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    187   1.4   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    188   1.4   pooka 
    189   1.4   pooka 	# restart server with failed component
    190   1.3   pooka 	rump.halt
    191   1.4   pooka 	rm disk0.img # FAIL
    192   1.9   oster 	atf_check -s exit:0 ${raidserver} 				\
    193   1.4   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    194   1.4   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    195   1.4   pooka 	    ${RUMP_SERVER}
    196   1.4   pooka 
    197   1.4   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    198   1.3   pooka }
    199   1.3   pooka 
    200   1.4   pooka raid1_comp0fail_cleanup()
    201   1.4   pooka {
    202   1.4   pooka 	export RUMP_SERVER=unix://sock
    203   1.4   pooka 	rump.halt
    204   1.4   pooka }
    205   1.4   pooka 
    206   1.9   oster atf_test_case raid1_normal cleanup
    207   1.9   oster raid1_normal_head()
    208   1.9   oster {
    209   1.9   oster 	atf_set "descr" "Checks that RAID1 -c configurations work " \
    210   1.9   oster 		"in the normal case"
    211  1.12   joerg 	atf_set "require.progs" "rump_server"
    212   1.9   oster }
    213   1.9   oster 
    214   1.9   oster raid1_normal_body()
    215   1.9   oster {
    216   1.9   oster 	makecfg 1 2
    217  1.10  martin 	export RUMP_SERVER=unix://sock
    218   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    219   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    220   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    221   1.9   oster             ${RUMP_SERVER}
    222   1.9   oster 
    223   1.9   oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    224   1.9   oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    225   1.9   oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    226   1.9   oster 
    227   1.9   oster         # put some data there
    228   1.9   oster         atf_check -s exit:0 -e ignore \
    229   1.9   oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    230   1.9   oster         atf_check -s exit:0 -e ignore -x \
    231   1.9   oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    232   1.9   oster 
    233   1.9   oster         # restart server, disks remain normal 
    234   1.9   oster         rump.halt
    235   1.9   oster 
    236   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    237   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    238   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    239   1.9   oster             ${RUMP_SERVER}
    240   1.9   oster 
    241   1.9   oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    242   1.9   oster 
    243   1.9   oster         # check if we we get what we wrote
    244   1.9   oster         atf_check -s exit:0 -o file:testfile -e ignore \
    245   1.9   oster             rump.dd if=${rawraid} count=4
    246   1.9   oster 
    247   1.9   oster }
    248   1.9   oster 
    249  1.11    gson raid1_normal_cleanup()
    250   1.9   oster {       
    251   1.9   oster         export RUMP_SERVER=unix://sock
    252   1.9   oster         rump.halt
    253   1.9   oster }
    254   1.9   oster 
    255   1.4   pooka 
    256   1.3   pooka atf_test_case raid5_compfail cleanup
    257   1.3   pooka raid5_compfail_head()
    258   1.3   pooka {
    259   1.3   pooka 	atf_set "descr" "Checks that RAID5 works after component failure"
    260  1.12   joerg 	atf_set "require.progs" "rump_server"
    261   1.3   pooka }
    262   1.3   pooka 
    263   1.3   pooka raid5_compfail_body()
    264   1.3   pooka {
    265   1.3   pooka 	makecfg 5 3
    266   1.3   pooka 	export RUMP_SERVER=unix://sock
    267   1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    268   1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    269   1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    270   1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    271   1.3   pooka 	    ${RUMP_SERVER}
    272   1.3   pooka 
    273   1.3   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    274   1.3   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    275   1.3   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    276   1.3   pooka 
    277   1.3   pooka 	# put some data there
    278   1.3   pooka 	atf_check -s exit:0 -e ignore \
    279   1.3   pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    280   1.8    jmmv 	atf_check -s exit:0 -e ignore -x \
    281   1.6   pooka 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    282   1.3   pooka 
    283   1.3   pooka 	# restart server with failed component
    284   1.3   pooka 	rump.halt
    285   1.3   pooka 	rm disk2.img # FAIL
    286   1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    287   1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    288   1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    289   1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    290   1.3   pooka 	    ${RUMP_SERVER}
    291   1.3   pooka 
    292   1.3   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    293   1.3   pooka 
    294   1.3   pooka 	# check if we we get what we wrote
    295   1.6   pooka 	atf_check -s exit:0 -o file:testfile -e ignore \
    296   1.6   pooka 	    rump.dd if=${rawraid} count=4
    297   1.3   pooka }
    298   1.3   pooka 
    299   1.3   pooka raid5_compfail_cleanup()
    300   1.3   pooka {
    301   1.3   pooka 	export RUMP_SERVER=unix://sock
    302   1.3   pooka 	rump.halt
    303   1.3   pooka }
    304   1.3   pooka 
    305   1.9   oster atf_test_case raid5_normal cleanup
    306   1.9   oster raid5_normal_head()
    307   1.9   oster {
    308   1.9   oster         atf_set "descr" "Checks that RAID5 works after normal shutdown " \
    309   1.9   oster 		"and 'raidctl -c' startup"
    310  1.12   joerg 	atf_set "require.progs" "rump_server"
    311   1.9   oster }
    312   1.9   oster 
    313   1.9   oster raid5_normal_body()
    314   1.9   oster {
    315   1.9   oster         makecfg 5 3
    316   1.9   oster         export RUMP_SERVER=unix://sock
    317   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    318   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    319   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    320   1.9   oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    321   1.9   oster             ${RUMP_SERVER}
    322   1.9   oster 
    323   1.9   oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    324   1.9   oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    325   1.9   oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    326   1.9   oster 
    327   1.9   oster         # put some data there
    328   1.9   oster         atf_check -s exit:0 -e ignore \
    329   1.9   oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    330   1.9   oster         atf_check -s exit:0 -e ignore -x \
    331   1.9   oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    332   1.9   oster 
    333   1.9   oster         # restart server after normal shutdown
    334   1.9   oster         rump.halt
    335   1.9   oster 
    336   1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    337   1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    338   1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    339   1.9   oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    340   1.9   oster             ${RUMP_SERVER}
    341   1.9   oster 
    342   1.9   oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    343   1.9   oster 
    344   1.9   oster         # check if we we get what we wrote
    345   1.9   oster         atf_check -s exit:0 -o file:testfile -e ignore \
    346   1.9   oster             rump.dd if=${rawraid} count=4
    347   1.9   oster }
    348   1.9   oster 
    349   1.9   oster raid5_normal_cleanup()
    350   1.9   oster {
    351   1.9   oster         export RUMP_SERVER=unix://sock
    352   1.9   oster         rump.halt
    353   1.9   oster }
    354   1.4   pooka 
    355   1.1   pooka atf_init_test_cases()
    356   1.1   pooka {
    357   1.1   pooka 	atf_add_test_case smalldisk
    358  1.13     mrg 	atf_add_test_case old_numrows_config
    359   1.9   oster 	atf_add_test_case raid1_normal
    360   1.4   pooka 	atf_add_test_case raid1_comp0fail
    361   1.3   pooka 	atf_add_test_case raid1_compfail
    362   1.9   oster 	atf_add_test_case raid5_normal
    363   1.3   pooka 	atf_add_test_case raid5_compfail
    364   1.1   pooka }
    365