From: claudio Date: Tue, 13 Apr 2021 07:39:17 +0000 (+0000) Subject: Add a basic regress test to test the 'rde evaluate all' feature. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c4391e92057cbb28fdbedb3fe5bc8761a8d5013b;p=openbsd Add a basic regress test to test the 'rde evaluate all' feature. --- diff --git a/regress/usr.sbin/bgpd/integrationtests/Makefile b/regress/usr.sbin/bgpd/integrationtests/Makefile index 2a100147773..a0399c9c1f2 100644 --- a/regress/usr.sbin/bgpd/integrationtests/Makefile +++ b/regress/usr.sbin/bgpd/integrationtests/Makefile @@ -1,7 +1,8 @@ -# $OpenBSD: Makefile,v 1.13 2021/02/10 16:37:29 claudio Exp $ +# $OpenBSD: Makefile,v 1.14 2021/04/13 07:39:17 claudio Exp $ REGRESS_TARGETS = network_statement md5 ovs mrt \ - maxprefix maxprefixout as0 med + maxprefix maxprefixout as0 med \ + eval_all BGPD ?= /usr/sbin/bgpd @@ -43,14 +44,15 @@ med: ${.IMPSRC} > ${.TARGET} || \ (rm ${.TARGET} && exit 1) -AS0_CONFS = exabgp.as0.test1.conf exabgp.as0.test2.conf - -as0: api-exabgp ${AS0_CONFS} +as0: api-exabgp exabgp.as0.test1.conf exabgp.as0.test2.conf ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12 med: api-exabgp exabgp.med.conf ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12 +eval_all: api-exabgp exabgp.eval_all.conf + ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12 + .endif .include diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.eval_all.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.eval_all.conf new file mode 100644 index 00000000000..7077aa04c70 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.eval_all.conf @@ -0,0 +1,25 @@ +AS 64500 +router-id 10.12.57.1 +fib-update no + +log updates +rde evaluate all + +neighbor 10.12.57.2 { + remote-as 64501 +} +neighbor 10.12.57.3 { + remote-as 64502 +} +neighbor 10.12.57.4 { + remote-as 64503 +} +neighbor 10.12.57.5 { + remote-as 64504 + rde evaluate default +} + +allow from any + +allow to any +deny to any community local-as:neighbor-as diff --git a/regress/usr.sbin/bgpd/integrationtests/eval_all.ok b/regress/usr.sbin/bgpd/integrationtests/eval_all.ok new file mode 100644 index 00000000000..8b3891ef259 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/eval_all.ok @@ -0,0 +1,32 @@ + +BGP routing table entry for 10.12.1.0/24 + 64501 + Nexthop 10.12.57.2 (via 10.12.57.2) Neighbor 10.12.57.3 (10.12.57.3) + Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external, valid + +BGP routing table entry for 10.12.2.0/24 + 64501 + Nexthop 10.12.57.2 (via 10.12.57.2) Neighbor 10.12.57.3 (10.12.57.3) + Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external, valid + Communities: 64500:64503 64500:64504 + +BGP routing table entry for 10.12.3.0/24 + 64501 + Nexthop 10.12.57.2 (via 10.12.57.2) Neighbor 10.12.57.3 (10.12.57.3) + Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external, valid + Communities: 64500:64503 64500:64504 + +BGP routing table entry for 10.12.1.0/24 + 64501 + Nexthop 10.12.57.2 (via 10.12.57.2) Neighbor 10.12.57.4 (10.12.57.4) + Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external, valid + +BGP routing table entry for 10.12.2.0/24 + 64502 + Nexthop 10.12.57.3 (via 10.12.57.3) Neighbor 10.12.57.4 (10.12.57.4) + Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external, valid + +BGP routing table entry for 10.12.1.0/24 + 64501 + Nexthop 10.12.57.2 (via 10.12.57.2) Neighbor 10.12.57.5 (10.12.57.5) + Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external, valid diff --git a/regress/usr.sbin/bgpd/integrationtests/eval_all.sh b/regress/usr.sbin/bgpd/integrationtests/eval_all.sh new file mode 100644 index 00000000000..ec1b631cc89 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/eval_all.sh @@ -0,0 +1,119 @@ +#!/bin/ksh +# $OpenBSD: eval_all.sh,v 1.1 2021/04/13 07:39:17 claudio Exp $ + +set -e + +BGPD=$1 +BGPDCONFIGDIR=$2 +RDOMAIN1=$3 +RDOMAIN2=$4 +PAIR1=$5 +PAIR2=$6 + +RDOMAINS="${RDOMAIN1} ${RDOMAIN2}" +PAIRS="${PAIR1} ${PAIR2}" +PAIR1IP=10.12.57.1 +PAIR2IP=10.12.57.2 +PAIR2IP2=10.12.57.3 +PAIR2IP3=10.12.57.4 +PAIR2IP4=10.12.57.5 + +error_notify() { + echo cleanup + pkill -T ${RDOMAIN1} bgpd || true + pkill -T ${RDOMAIN2} -f exabgp || true + sleep 1 + ifconfig ${PAIR2} destroy || true + ifconfig ${PAIR1} destroy || true + route -qn -T ${RDOMAIN1} flush || true + route -qn -T ${RDOMAIN2} flush || true + ifconfig lo${RDOMAIN1} destroy || true + ifconfig lo${RDOMAIN2} destroy || true + if [ $1 -ne 0 ]; then + echo FAILED + exit 1 + else + echo SUCCESS + fi +} + +run_exabgp() { + local _t=$1 + + shift + env exabgp.log.destination=stdout \ + exabgp.log.packets=true \ + exabgp.log.parser=true \ + exabgp.log.level=DEBUG \ + exabgp.api.cli=false \ + exabgp.daemon.user=build \ + route -T ${RDOMAIN2} exec exabgp -1 ${1+"$@"} > ./exabgp.$_t.log +} + +exacmd() { + echo "${1+"$@"}" > eval_all.fifo + sleep .1 # give exabgp a bit of time +} + +if [ ! -x /usr/local/bin/exabgp ]; then + echo install exabgp from ports for this test >&2 + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo need root privileges >&2 + exit 1 +fi + +trap 'error_notify $?' EXIT + +echo check if rdomains are busy +for n in ${RDOMAINS}; do + if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then + echo routing domain ${n} is already used >&2 + exit 1 + fi +done + +echo check if interfaces are busy +for n in ${PAIRS}; do + /sbin/ifconfig "${n}" >/dev/null 2>&1 && \ + ( echo interface ${n} is already used >&2; exit 1 ) +done + +set -x + +echo setup +ifconfig ${PAIR1} rdomain ${RDOMAIN1} ${PAIR1IP}/29 up +ifconfig ${PAIR2} rdomain ${RDOMAIN2} ${PAIR2IP}/29 up +ifconfig ${PAIR2} alias ${PAIR2IP2}/32 +ifconfig ${PAIR2} alias ${PAIR2IP3}/32 +ifconfig ${PAIR2} alias ${PAIR2IP4}/32 +ifconfig ${PAIR1} patch ${PAIR2} +ifconfig lo${RDOMAIN1} inet 127.0.0.1/8 +ifconfig lo${RDOMAIN2} inet 127.0.0.1/8 + +[ -p eval_all.fifo ] || mkfifo eval_all.fifo + +echo run bgpd +route -T ${RDOMAIN1} exec ${BGPD} \ + -v -f ${BGPDCONFIGDIR}/bgpd.eval_all.conf + +sleep 1 + +echo run exabgp +run_exabgp eval_all exabgp.eval_all.conf & +sleep 2 + +echo test 1 + +sleep 5 +route -T ${RDOMAIN1} exec bgpctl sh rib detail +route -T ${RDOMAIN1} exec bgpctl sh rib out detail | \ + grep -v 'Last update:' | tee eval_all.out +sleep .2 +diff -u ${BGPDCONFIGDIR}/eval_all.ok eval_all.out +echo OK + +exacmd 'shutdown' +exit 0 diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.eval_all.in b/regress/usr.sbin/bgpd/integrationtests/exabgp.eval_all.in new file mode 100644 index 00000000000..348c44fff1f --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.eval_all.in @@ -0,0 +1,72 @@ +process reader { + run "##OBJDIR##/api-exabgp" "##OBJDIR##/eval_all.fifo"; + encoder text; +} + +neighbor 10.12.57.1 { + router-id 10.12.57.2; + local-address 10.12.57.2; + local-as 64501; + peer-as 64500; + group-updates; + adj-rib-in false; + passive false; + + family { + ipv4 unicast; + } + + static { + route 10.12.1.0/24 next-hop self; + route 10.12.2.0/24 next-hop self community [ 64500:64503 64500:64504 ]; + route 10.12.3.0/24 next-hop self community [ 64500:64503 64500:64504 ]; + } +} + +neighbor 10.12.57.1 { + router-id 10.12.57.3; + local-address 10.12.57.3; + local-as 64502; + peer-as 64500; + group-updates; + adj-rib-in false; + passive false; + + family { + ipv4 unicast; + } + + static { + route 10.12.1.0/24 next-hop self; + route 10.12.2.0/24 next-hop self; + route 10.12.3.0/24 next-hop self community [ 64500:64503 64500:64504 ]; + } +} + +neighbor 10.12.57.1 { + router-id 10.12.57.4; + local-address 10.12.57.4; + local-as 64503; + peer-as 64500; + group-updates; + adj-rib-in false; + passive false; + + family { + ipv4 unicast; + } +} + +neighbor 10.12.57.1 { + router-id 10.12.57.5; + local-address 10.12.57.5; + local-as 64504; + peer-as 64500; + group-updates; + adj-rib-in false; + passive false; + + family { + ipv4 unicast; + } +}