From 739e1c62b041461da4ca05a21dc41db8bbe4dcbf Mon Sep 17 00:00:00 2001 From: shemminger Date: Mon, 24 May 2004 22:47:43 +0000 Subject: Put tests in CVS --- tests/README | 14 +++++ tests/busybr | 23 ++++++++ tests/functest | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/mkbr | 13 +++++ tests/rmbr | 11 ++++ tests/showme | 10 ++++ tests/stresstest | 66 +++++++++++++++++++++ 7 files changed, 308 insertions(+) create mode 100644 tests/README create mode 100755 tests/busybr create mode 100755 tests/functest create mode 100755 tests/mkbr create mode 100755 tests/rmbr create mode 100755 tests/showme create mode 100755 tests/stresstest diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..81a40bc --- /dev/null +++ b/tests/README @@ -0,0 +1,14 @@ +This is a set of shell scripts for testing Ethernet bridging. + +mkbr makes a simple bridge and clones the ip address. +rmbr removes bridge + +The functional test needs two ethernets (eth0, eth1, +and the dummy network device. It may screw up your route +table. Also, it leaves eth0 in an bad state if test fails. + +The stresstest needs two ethernets (eth0 and eth1). +For highest stress, traffic should be sent over the bridge +while the test is ongoing. The goal is to exercise, races +that occur when traffic is flowing while management operations occur. + diff --git a/tests/busybr b/tests/busybr new file mode 100755 index 0000000..bdaed46 --- /dev/null +++ b/tests/busybr @@ -0,0 +1,23 @@ +#! /bin/sh +BR=${1:-"br549"} +ETH0=${1:-"eth0"} +ETH1=${1:-"eth1"} + +# fetch ip of working br0 +IP=`/sbin/ifconfig $BR | sed -n -e 's/^.*inet addr:\([0-9][0-9\.]*\).*$/\1/p'` +echo "Using IP address $IP" + +while true; +do + ifconfig $BR down + brctl delbr $BR + ifconfig $ETH0 $IP + + ifconfig $ETH0 0.0.0.0 + brctl addbr $BR + brctl addif $BR $ETH0 + brctl addif $BR $ETH1 + ifconfig $BR $IP + + sleep 10 +done diff --git a/tests/functest b/tests/functest new file mode 100755 index 0000000..a321c59 --- /dev/null +++ b/tests/functest @@ -0,0 +1,171 @@ +#! /bin/bash +BR=${1:-"br549"} +ETH=${2:-"eth0"} +maxports=${3:-1000} + +echo "Ethernet Bridge functional test" + +echo -n "Testing kernel: " ; uname -a +echo -n "Utilities: " ; brctl -V + +# fetch ip of working $ETH +IP=`/sbin/ifconfig $ETH | sed -n -e 's/^.*inet addr:\([0-9][0-9\.]*\).*$/\1/p'` +echo "Using IP address $IP" + +# All commands in this part must succeed +set -e + +echo "0. Creating $maxports dummy devices" +modprobe dummy numdummies=$maxports + +echo "1. Creating bridge $BR" +brctl addbr $BR +brctl stp $BR on + +echo "2. Add $ETH" +ifconfig $ETH 0.0.0.0 +brctl addif $BR $ETH + +echo "3. Bring up bridge" +ifconfig $BR $IP + +echo "4 Bring up another bridge" +brctl addbr "brx%d" +ifconfig brx0 1.1.1.1 + +echo "5 Bring down bridge" +ifconfig brx0 down +brctl delbr brx0 + +echo -n "6. Add " $maxports " ports:" +for (( i=1; i < $maxports; i++)) +do + brctl addif $BR dummy$i + if [[ $(( $i % 10 )) -eq 10 ]] + then echo -n '.' + fi +done +echo + +echo -n "7. Delete those ports:" +for (( i=1; i < $maxports; i++)) +do + brctl delif $BR dummy$i + if [[ $(( $i % 10 )) -eq 10 ]] + then echo -n '.' + fi +done +echo + +echo "8. Notififer cases" +brctl addif $BR dummy0 + +echo "8a Device down" +ifconfig dummy0 down + +echo "8b Change device address" +ifconfig dummy0 hw ether 00:0d:02:03:04:05 + +echo "8c. Device up" +ifconfig dummy0 up + +echo "8d Unregister device (slow)" +rmmod dummy +echo "** Done" + +modprobe dummy numdummies=2 + +set +e + +echo "10 Error cases" +echo -n " duplicate bridge - " +brctl addbr $BR + +echo -n " bridge to bridge - " +brctl addbr brTmp +brctl addif $BR brTmp + +echo -n " already in other bridge - " +brctl addif brTmp $ETH + +echo -n " already in this bridge - " +brctl addif $BR $ETH + +echo -n " remove from wrong bridge - " +brctl delif brTmp $ETH +brctl delbr brTmp + +echo -n " remove bridge $ETH - " +brctl delbr $ETH + +echo -n " remove bridge bogus - " +brctl delbr bogus + +echo -n " remove still active bridge - " +brctl delbr $BR + +echo -n " zero hw address - " +ifconfig dummy0 hw ether 00:00:00:00:00:00 +brctl addif $BR dummy0 + +echo -n " duplicate hw address - " +ifconfig dummy0 hw ether 00:0d:01:00:00:00 +ifconfig dummy1 hw ether 00:0d:01:00:00:00 +brctl addif $BR dummy0 +brctl addif $BR dummy1 +# leave dummy0 for next test. + +echo "10 Tuning" +set -e +brctl stp $BR off +brctl stp $BR on +brctl setageing $BR 4000 +brctl setbridgeprio $BR 1 +brctl setfd $BR 120 +brctl sethello $BR 20 +brctl setmaxage $BR 1000 +brctl setpathcost $BR dummy0 50 +brctl setportprio $BR dummy0 2 + +echo "Status check" +brctl show +read -p "Ok?" +brctl showstp $BR +read -p "Ok?" +brctl showmacs $BR +read -p "Ok?" + + +echo "30 Shutdown" +ifconfig $BR down +brctl delbr $BR +ifconfig $ETH $IP + +echo "31 Remove bridge module" +rmmod bridge +rmmod dummy +rmmod bridge + +echo "32 Check for dead bridge cleanup" +brctl addbr $BR +rmmod bridge +modprobe bridge +sleep 1 + +echo "33 Remove module with race" +brctl addbr $BR +ifconfig $BR 9.9.9.9 + +rmmod --wait bridge & +sleep 2 +brctl addbr brXX +if ifconfig brXX 1.1.1.1 ; then + echo "?? ifconfig succeeded" + ifconfig brXX down +fi + +ifconfig $BR down +wait + +echo "*** Done ***" + diff --git a/tests/mkbr b/tests/mkbr new file mode 100755 index 0000000..1d64e82 --- /dev/null +++ b/tests/mkbr @@ -0,0 +1,13 @@ +#! /bin/sh + +BR=${1:-"br549"} +ETH=${2:-"eth0"} + +# fetch ip of working eth0 +IP=`/sbin/ifconfig $ETH | sed -n -e 's/^.*inet addr:\([0-9][0-9\.]*\).*$/\1/p'` +echo "Using IP address $IP" + +ifconfig $ETH 0.0.0.0 +brctl addbr $BR +brctl addif $BR $ETH +ifconfig $BR $IP diff --git a/tests/rmbr b/tests/rmbr new file mode 100755 index 0000000..8d1dc30 --- /dev/null +++ b/tests/rmbr @@ -0,0 +1,11 @@ +#! /bin/sh +BR=${1:-"br549"} + +# fetch ip of working br0 +IP=`/sbin/ifconfig $BR | sed -n -e 's/^.*inet addr:\([0-9][0-9\.]*\).*$/\1/p'` +echo "Using IP address $IP" + +ifconfig $BR down +brctl delbr $BR +ifconfig eth0 172.20.5.22 +rmmod bridge diff --git a/tests/showme b/tests/showme new file mode 100755 index 0000000..7bc869e --- /dev/null +++ b/tests/showme @@ -0,0 +1,10 @@ +#!/bin/bash +BR=${1:-"br549"} + +while true; +do + brctl show + brctl showstp $BR + brctl showmacs $BR + sleep 5 +done diff --git a/tests/stresstest b/tests/stresstest new file mode 100755 index 0000000..5d529d8 --- /dev/null +++ b/tests/stresstest @@ -0,0 +1,66 @@ +#! /bin/bash + +BR=${1:-"br549"} +ETH0=${2:-"eth0"} +ETH1=${3:-"eth1"} +ETH2=${4:-"eth1"} + +echo "Ethernet Bridge stress test" + +IP=`/sbin/ifconfig $ETH0 | sed -n -e 's/^.*inet addr:\([0-9][0-9\.]*\).*$/\1/p'` +echo $IP + +inout() { + while true; + do + brctl addif $1 $2 + sleep $(($RANDOM % 10)) + brctl delif $1 $2 + done +} + +newdel() { + while true; + do + brctl addbr $1 + brctl delbr $1 + done +} + +updown() { + while true; + do + ifconfig $1 down + ifconfig $1 up + sleep 11 + done +} + +echo "1. Creating bridge $BR" +brctl addbr $BR + +echo -n "2. Add ethernets" +ifconfig $ETH0 0.0.0.0 +brctl addif $BR $ETH0 +echo -n $ETH0 +ifconfig $ETH2 0.0.0.0 +brctl addif $BR $ETH2 +echo $ETH2 + +echo "4. Starting add/del interface" $ETH1 +ifconfig $ETH1 0.0.0.0 +inout $BR $ETH1 & +ipid=$! + +echo "5. Starting add/remove bridge" +newdel brtmp1 & +npid=$! + +echo "6. Starting up/down" $ETH1 +updown $BR $ETH1 & +upid=$! + +trap "kill $ipid $npid $upid" 1 2 3 15 + +echo " Waiting" +wait -- cgit v1.2.3