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