diff options
author | Anton Lindqvist <anton@cvs.openbsd.org> | 2024-01-28 12:36:22 +0000 |
---|---|---|
committer | Anton Lindqvist <anton@cvs.openbsd.org> | 2024-01-28 12:36:22 +0000 |
commit | 8511762a57552154007bbdcbf8bce4ba28e60032 (patch) | |
tree | 2ff388e0aeb327a8f2642b67302e0faa186b8c44 /regress/usr.sbin | |
parent | 43e963f92a60d236fb79b760775a0889f3bbb293 (diff) |
Use the wait until construct in ixp.sh in the hopes of making it more
stable.
Diffstat (limited to 'regress/usr.sbin')
-rw-r--r-- | regress/usr.sbin/bgpd/integrationtests/ixp.sh | 10 | ||||
-rw-r--r-- | regress/usr.sbin/bgpd/integrationtests/network_statement.sh | 32 | ||||
-rw-r--r-- | regress/usr.sbin/bgpd/integrationtests/util.sh | 11 |
3 files changed, 22 insertions, 31 deletions
diff --git a/regress/usr.sbin/bgpd/integrationtests/ixp.sh b/regress/usr.sbin/bgpd/integrationtests/ixp.sh index ae4b1d152e4..8779285019a 100644 --- a/regress/usr.sbin/bgpd/integrationtests/ixp.sh +++ b/regress/usr.sbin/bgpd/integrationtests/ixp.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: ixp.sh,v 1.1 2023/10/12 09:18:56 claudio Exp $ +# $OpenBSD: ixp.sh,v 1.2 2024/01/28 12:36:21 anton Exp $ set -e @@ -43,6 +43,8 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi +. "${BGPDCONFIGDIR}/util.sh" + trap 'error_notify $?' EXIT echo check if rdomains are busy @@ -84,17 +86,15 @@ route -T ${RDOMAIN2} exec ${BGPD} \ route -T ${RDOMAIN2} exec ${BGPD} \ -v -f ${BGPDCONFIGDIR}/bgpd.ixp.rdomain2_4.conf -sleep 3 - +wait_until "route -T ${RDOMAIN1} exec bgpctl show rib detail | ! cmp /dev/null -" route -T ${RDOMAIN1} exec bgpctl show rib detail | grep -v 'Last update:' | \ tee ixp.rdomain1.out -sleep .2 diff -u ${BGPDCONFIGDIR}/ixp.rdomain1.ok ixp.rdomain1.out echo OK +wait_until "route -T ${RDOMAIN2} exec bgpctl show rib detail | ! cmp /dev/null -" route -T ${RDOMAIN2} exec bgpctl show rib detail | grep -v 'Last update:' | \ tee ixp.rdomain2.out -sleep .2 diff -u ${BGPDCONFIGDIR}/ixp.rdomain2.ok ixp.rdomain2.out echo OK diff --git a/regress/usr.sbin/bgpd/integrationtests/network_statement.sh b/regress/usr.sbin/bgpd/integrationtests/network_statement.sh index 66c704ed5eb..8925dbf3ef1 100644 --- a/regress/usr.sbin/bgpd/integrationtests/network_statement.sh +++ b/regress/usr.sbin/bgpd/integrationtests/network_statement.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: network_statement.sh,v 1.8 2023/02/15 14:19:08 claudio Exp $ +# $OpenBSD: network_statement.sh,v 1.9 2024/01/28 12:36:21 anton Exp $ set -e @@ -34,7 +34,6 @@ error_notify() { route -qn -T ${RDOMAIN2} flush || true ifconfig lo${RDOMAIN1} destroy || true ifconfig lo${RDOMAIN2} destroy || true - rm -f ${TMP} if [ $1 -ne 0 ]; then echo FAILED exit 1 @@ -43,27 +42,14 @@ error_notify() { fi } -wait_until() { - local _i=0 - - cat >"$TMP" - while [ "$_i" -lt 8 ]; do - sh -x "$TMP" && return 0 - sleep 0.5 - _i="$((_i + 1))" - done - echo timeout - return 1 -} - if [ "$(id -u)" -ne 0 ]; then echo need root privileges >&2 exit 1 fi -trap 'error_notify $?' EXIT +. "${BGPDCONFIGDIR}/util.sh" -TMP="$(mktemp -t bgpd.XXXXXX)" +trap 'error_notify $?' EXIT echo check if rdomains are busy for n in ${RDOMAINS}; do @@ -104,9 +90,7 @@ sleep 1 route -T ${RDOMAIN1} exec bgpctl nei RDOMAIN2 up sleep 1 -wait_until <<EOF -route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | grep -q ${PAIR2STATIC} -EOF +wait_until "route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | grep -q ${PAIR2STATIC}" echo test 1 route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | \ @@ -128,9 +112,7 @@ route -T ${RDOMAIN2} delete -label PAIR2RTABLE ${PAIR2RTABLE} \ route -T ${RDOMAIN2} delete -priority 55 ${PAIR2PRIORITY} \ ${PAIR1IP} -wait_until <<EOF -route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | ! grep -q ${PAIR2STATIC} -EOF +wait_until "route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | ! grep -q ${PAIR2STATIC}" echo test 2 route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | \ @@ -150,9 +132,7 @@ route -T ${RDOMAIN2} add -label PAIR2RTABLE ${PAIR2RTABLE} \ route -T ${RDOMAIN2} add -priority 55 ${PAIR2PRIORITY} \ ${PAIR1IP} -wait_until <<EOF -route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | grep -q ${PAIR2STATIC} -EOF +wait_until "route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | grep -q ${PAIR2STATIC}" echo test 3 route -T ${RDOMAIN1} exec bgpctl sh rib ${PAIR2STATIC} | \ diff --git a/regress/usr.sbin/bgpd/integrationtests/util.sh b/regress/usr.sbin/bgpd/integrationtests/util.sh new file mode 100644 index 00000000000..bc6470ce3ab --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/util.sh @@ -0,0 +1,11 @@ +wait_until() { + local _i=0 + + while [ "$_i" -lt 8 ]; do + sh -x -c "$*" && return 0 + sleep 0.5 + _i="$((_i + 1))" + done + echo timeout + return 1 +} |