Skip to content

Commit

Permalink
smoke: unconfigure everything at the end
Browse files Browse the repository at this point in the history
To allow running smoke tests with a manually started grout in a separate
terminal without restarting the daemon, cleanup all configured objects
before ending the tests.

Signed-off-by: Robin Jarry <robin@jarry.cc>
  • Loading branch information
rjarry committed Oct 30, 2024
1 parent 9c5f3b4 commit 7d2909c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions smoke/_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,38 @@ fi
cleanup() {
set +e
sh -x $tmp/cleanup

# delete all non-port interfaces first
grcli show interface all |
grep -Ev -e ^NAME -e '\<port[[:space:]]+devargs=' |
while read -r name _; do
grcli del interface "$name"
done
# then delete all ports
grcli show interface all |
grep -v ^NAME |
while read -r name _; do
grcli del interface "$name"
done
# delete all routes
grcli show ip route | grep -v ^VRF |
while read -r vrf route _; do
grcli del ip route $route vrf $vrf
done
grcli show ip6 route | grep -v ^VRF |
while read -r vrf route nh; do
grcli del ip6 route $route vrf $vrf
done
# delete all nexthops
grcli show ip nexthop | grep -v ^VRF |
while read -r vrf ip _; do
grcli del ip nexthop $ip vrf $vrf
done
grcli show ip6 nexthop | grep -v ^VRF |
while read -r vrf ip _; do
grcli del ip6 nexthop $ip vrf $vrf
done

if [ "$run_grout" = true ]; then
kill -INT %?grout
wait
Expand Down

0 comments on commit 7d2909c

Please sign in to comment.