Home | History | Annotate | Line # | Download | only in raidframe
t_raid.sh revision 1.11.8.1
      1       1.9   oster #! /usr/bin/atf-sh
      2  1.11.8.1     tls #	$NetBSD: t_raid.sh,v 1.11.8.1 2013/02/25 00:30:20 tls 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.11.8.1     tls 	atf_set "require.progs" "rump_server"
     55       1.1   pooka }
     56       1.1   pooka 
     57       1.1   pooka smalldisk_body()
     58       1.1   pooka {
     59       1.1   pooka 	makecfg 1 2
     60       1.1   pooka 	export RUMP_SERVER=unix://sock
     61       1.5   pooka 	atf_check -s exit:0 ${raidserver}			\
     62       1.1   pooka 	    -d key=/disk0,hostpath=disk0.img,size=1m		\
     63       1.1   pooka 	    -d key=/disk1,hostpath=disk1.img,size=1m		\
     64       1.1   pooka 	    ${RUMP_SERVER}
     65       1.1   pooka 
     66       1.1   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
     67       1.1   pooka }
     68       1.1   pooka 
     69       1.1   pooka smalldisk_cleanup()
     70       1.1   pooka {
     71       1.1   pooka 	export RUMP_SERVER=unix://sock
     72       1.1   pooka 	rump.halt
     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.11.8.1     tls 	atf_set "require.progs" "rump_server"
     84       1.3   pooka }
     85       1.3   pooka 
     86       1.3   pooka raid1_compfail_body()
     87       1.3   pooka {
     88       1.3   pooka 	makecfg 1 2
     89       1.3   pooka 	export RUMP_SERVER=unix://sock
     90       1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
     91       1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
     92       1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
     93       1.3   pooka 	    ${RUMP_SERVER}
     94       1.3   pooka 
     95       1.3   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
     96       1.3   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
     97       1.3   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
     98       1.3   pooka 
     99       1.3   pooka 	# put some data there
    100       1.3   pooka 	atf_check -s exit:0 -e ignore \
    101       1.3   pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    102       1.8    jmmv 	atf_check -s exit:0 -e ignore -x \
    103       1.6   pooka 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    104       1.3   pooka 
    105       1.3   pooka 	# restart server with failed component
    106       1.3   pooka 	rump.halt
    107       1.3   pooka 	rm disk1.img # FAIL
    108       1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    109       1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    110       1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    111       1.3   pooka 	    ${RUMP_SERVER}
    112       1.3   pooka 
    113       1.3   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    114       1.3   pooka 
    115       1.3   pooka 	# check if we we get what we wrote
    116       1.6   pooka 	atf_check -s exit:0 -o file:testfile -e ignore \
    117       1.6   pooka 	    rump.dd if=${rawraid} count=4
    118       1.3   pooka }
    119       1.3   pooka 
    120       1.3   pooka raid1_compfail_cleanup()
    121       1.3   pooka {
    122       1.4   pooka 	export RUMP_SERVER=unix://sock
    123       1.4   pooka 	rump.halt
    124       1.4   pooka }
    125       1.4   pooka 
    126       1.4   pooka 
    127       1.4   pooka 
    128       1.4   pooka atf_test_case raid1_comp0fail cleanup
    129       1.4   pooka raid1_comp0fail_head()
    130       1.4   pooka {
    131       1.9   oster 	atf_set "descr" "Checks configuring RAID1 after component 0 fails" \
    132       1.9   oster 		"(PR kern/44251)"
    133  1.11.8.1     tls 	atf_set "require.progs" "rump_server"
    134       1.4   pooka }
    135       1.3   pooka 
    136       1.4   pooka raid1_comp0fail_body()
    137       1.4   pooka {
    138       1.4   pooka 	makecfg 1 2
    139       1.3   pooka 	export RUMP_SERVER=unix://sock
    140       1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    141       1.4   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    142       1.4   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    143       1.4   pooka 	    ${RUMP_SERVER}
    144       1.4   pooka 
    145       1.4   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    146       1.4   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    147       1.4   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    148       1.4   pooka 
    149       1.4   pooka 	# restart server with failed component
    150       1.3   pooka 	rump.halt
    151       1.4   pooka 	rm disk0.img # FAIL
    152       1.9   oster 	atf_check -s exit:0 ${raidserver} 				\
    153       1.4   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    154       1.4   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    155       1.4   pooka 	    ${RUMP_SERVER}
    156       1.4   pooka 
    157       1.4   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    158       1.3   pooka }
    159       1.3   pooka 
    160       1.4   pooka raid1_comp0fail_cleanup()
    161       1.4   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.9   oster atf_test_case raid1_normal cleanup
    167       1.9   oster raid1_normal_head()
    168       1.9   oster {
    169       1.9   oster 	atf_set "descr" "Checks that RAID1 -c configurations work " \
    170       1.9   oster 		"in the normal case"
    171  1.11.8.1     tls 	atf_set "require.progs" "rump_server"
    172       1.9   oster }
    173       1.9   oster 
    174       1.9   oster raid1_normal_body()
    175       1.9   oster {
    176       1.9   oster 	makecfg 1 2
    177      1.10  martin 	export RUMP_SERVER=unix://sock
    178       1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    179       1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    180       1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    181       1.9   oster             ${RUMP_SERVER}
    182       1.9   oster 
    183       1.9   oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    184       1.9   oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    185       1.9   oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    186       1.9   oster 
    187       1.9   oster         # put some data there
    188       1.9   oster         atf_check -s exit:0 -e ignore \
    189       1.9   oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    190       1.9   oster         atf_check -s exit:0 -e ignore -x \
    191       1.9   oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    192       1.9   oster 
    193       1.9   oster         # restart server, disks remain normal 
    194       1.9   oster         rump.halt
    195       1.9   oster 
    196       1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    197       1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    198       1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    199       1.9   oster             ${RUMP_SERVER}
    200       1.9   oster 
    201       1.9   oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    202       1.9   oster 
    203       1.9   oster         # check if we we get what we wrote
    204       1.9   oster         atf_check -s exit:0 -o file:testfile -e ignore \
    205       1.9   oster             rump.dd if=${rawraid} count=4
    206       1.9   oster 
    207       1.9   oster }
    208       1.9   oster 
    209      1.11    gson raid1_normal_cleanup()
    210       1.9   oster {       
    211       1.9   oster         export RUMP_SERVER=unix://sock
    212       1.9   oster         rump.halt
    213       1.9   oster }
    214       1.9   oster 
    215       1.4   pooka 
    216       1.3   pooka atf_test_case raid5_compfail cleanup
    217       1.3   pooka raid5_compfail_head()
    218       1.3   pooka {
    219       1.3   pooka 	atf_set "descr" "Checks that RAID5 works after component failure"
    220  1.11.8.1     tls 	atf_set "require.progs" "rump_server"
    221       1.3   pooka }
    222       1.3   pooka 
    223       1.3   pooka raid5_compfail_body()
    224       1.3   pooka {
    225       1.3   pooka 	makecfg 5 3
    226       1.3   pooka 	export RUMP_SERVER=unix://sock
    227       1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    228       1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    229       1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    230       1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    231       1.3   pooka 	    ${RUMP_SERVER}
    232       1.3   pooka 
    233       1.3   pooka 	atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    234       1.3   pooka 	atf_check -s exit:0 rump.raidctl -I 12345 raid0
    235       1.3   pooka 	atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    236       1.3   pooka 
    237       1.3   pooka 	# put some data there
    238       1.3   pooka 	atf_check -s exit:0 -e ignore \
    239       1.3   pooka 	    dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    240       1.8    jmmv 	atf_check -s exit:0 -e ignore -x \
    241       1.6   pooka 	    "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    242       1.3   pooka 
    243       1.3   pooka 	# restart server with failed component
    244       1.3   pooka 	rump.halt
    245       1.3   pooka 	rm disk2.img # FAIL
    246       1.5   pooka 	atf_check -s exit:0 ${raidserver}				\
    247       1.3   pooka 	    -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}	\
    248       1.3   pooka 	    -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}	\
    249       1.3   pooka 	    -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}	\
    250       1.3   pooka 	    ${RUMP_SERVER}
    251       1.3   pooka 
    252       1.3   pooka 	atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    253       1.3   pooka 
    254       1.3   pooka 	# check if we we get what we wrote
    255       1.6   pooka 	atf_check -s exit:0 -o file:testfile -e ignore \
    256       1.6   pooka 	    rump.dd if=${rawraid} count=4
    257       1.3   pooka }
    258       1.3   pooka 
    259       1.3   pooka raid5_compfail_cleanup()
    260       1.3   pooka {
    261       1.3   pooka 	export RUMP_SERVER=unix://sock
    262       1.3   pooka 	rump.halt
    263       1.3   pooka }
    264       1.3   pooka 
    265       1.9   oster atf_test_case raid5_normal cleanup
    266       1.9   oster raid5_normal_head()
    267       1.9   oster {
    268       1.9   oster         atf_set "descr" "Checks that RAID5 works after normal shutdown " \
    269       1.9   oster 		"and 'raidctl -c' startup"
    270  1.11.8.1     tls 	atf_set "require.progs" "rump_server"
    271       1.9   oster }
    272       1.9   oster 
    273       1.9   oster raid5_normal_body()
    274       1.9   oster {
    275       1.9   oster         makecfg 5 3
    276       1.9   oster         export RUMP_SERVER=unix://sock
    277       1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    278       1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    279       1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    280       1.9   oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    281       1.9   oster             ${RUMP_SERVER}
    282       1.9   oster 
    283       1.9   oster         atf_check -s exit:0 rump.raidctl -C raid.conf raid0
    284       1.9   oster         atf_check -s exit:0 rump.raidctl -I 12345 raid0
    285       1.9   oster         atf_check -s exit:0 -o ignore rump.raidctl -iv raid0
    286       1.9   oster 
    287       1.9   oster         # put some data there
    288       1.9   oster         atf_check -s exit:0 -e ignore \
    289       1.9   oster             dd if=$(atf_get_srcdir)/t_raid of=testfile count=4
    290       1.9   oster         atf_check -s exit:0 -e ignore -x \
    291       1.9   oster             "dd if=testfile | rump.dd of=${rawraid} conv=sync"
    292       1.9   oster 
    293       1.9   oster         # restart server after normal shutdown
    294       1.9   oster         rump.halt
    295       1.9   oster 
    296       1.9   oster         atf_check -s exit:0 ${raidserver}                               \
    297       1.9   oster             -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE}     \
    298       1.9   oster             -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE}     \
    299       1.9   oster             -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE}     \
    300       1.9   oster             ${RUMP_SERVER}
    301       1.9   oster 
    302       1.9   oster         atf_check -s exit:0 rump.raidctl -c raid.conf raid0
    303       1.9   oster 
    304       1.9   oster         # check if we we get what we wrote
    305       1.9   oster         atf_check -s exit:0 -o file:testfile -e ignore \
    306       1.9   oster             rump.dd if=${rawraid} count=4
    307       1.9   oster }
    308       1.9   oster 
    309       1.9   oster raid5_normal_cleanup()
    310       1.9   oster {
    311       1.9   oster         export RUMP_SERVER=unix://sock
    312       1.9   oster         rump.halt
    313       1.9   oster }
    314       1.4   pooka 
    315       1.1   pooka atf_init_test_cases()
    316       1.1   pooka {
    317       1.1   pooka 	atf_add_test_case smalldisk
    318       1.9   oster 	atf_add_test_case raid1_normal
    319       1.4   pooka 	atf_add_test_case raid1_comp0fail
    320       1.3   pooka 	atf_add_test_case raid1_compfail
    321       1.9   oster 	atf_add_test_case raid5_normal
    322       1.3   pooka 	atf_add_test_case raid5_compfail
    323       1.1   pooka }
    324