From b9ccfbe71be5adc69f0b8f9dfc4420261ae6c042 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sun, 24 Jan 2021 14:40:43 -0800 Subject: [PATCH] [vstest]: add default vs test Check #6483 add test to make sure default route change in eth0 does not affect the default route in the default vrf Signed-off-by: Guohan Lu --- .../tests/bgp/files/default_route/bgpd.conf | 4 ++ .../files/default_route/default_route.conf | 17 +++++++ platform/vs/tests/bgp/test_default_route.py | 48 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 platform/vs/tests/bgp/files/default_route/bgpd.conf create mode 100644 platform/vs/tests/bgp/files/default_route/default_route.conf create mode 100644 platform/vs/tests/bgp/test_default_route.py diff --git a/platform/vs/tests/bgp/files/default_route/bgpd.conf b/platform/vs/tests/bgp/files/default_route/bgpd.conf new file mode 100644 index 000000000000..bc0dffcdbb8b --- /dev/null +++ b/platform/vs/tests/bgp/files/default_route/bgpd.conf @@ -0,0 +1,4 @@ +router bgp 65501 + bgp router-id 1.1.1.1 + no bgp ebgp-requires-policy + neighbor 10.10.10.1 remote-as 65502 diff --git a/platform/vs/tests/bgp/files/default_route/default_route.conf b/platform/vs/tests/bgp/files/default_route/default_route.conf new file mode 100644 index 000000000000..9f9d3cf32f80 --- /dev/null +++ b/platform/vs/tests/bgp/files/default_route/default_route.conf @@ -0,0 +1,17 @@ +neighbor 10.10.10.0 { + router-id 1.2.3.4; + local-address 10.10.10.1; + local-as 65502; + peer-as 65501; + group-updates false; + + family { + ipv4 unicast; + } + + static { + route 0.0.0.0/0 { + next-hop 10.10.10.1; + } + } +} diff --git a/platform/vs/tests/bgp/test_default_route.py b/platform/vs/tests/bgp/test_default_route.py new file mode 100644 index 000000000000..2cc9021ba78e --- /dev/null +++ b/platform/vs/tests/bgp/test_default_route.py @@ -0,0 +1,48 @@ +from swsscommon import swsscommon +import os +import re +import time +import json +import pytest + +def test_DefaultRoute(dvs, testlog): + + dvs.copy_file("/etc/frr/", "bgp/files/default_route/bgpd.conf") + dvs.runcmd("supervisorctl start bgpd") + dvs.runcmd("ip addr add 10.10.10.0/31 dev Ethernet0") + dvs.runcmd("config interface startup Ethernet0") + dvs.runcmd("ip route del 0.0.0.0/0") + dvs.runcmd("vtysh -c \"confgure terminal\" -c \"ip route 0.0.0.0/0 via 172.17.0.1 200\"") + + dvs.servers[0].runcmd("ip addr add 10.10.10.1/31 dev eth0") + dvs.servers[0].runcmd("ifconfig eth0 up") + + time.sleep(5) + + print(dvs.runcmd("supervisorctl status")) + + p = dvs.servers[0].runcmd_async("exabgp -d bgp/files/default_route/default_route.conf") + + time.sleep(10) + + (exit_code, output) = dvs.runcmd(["redis-cli", "hgetall", "ROUTE_TABLE:0.0.0.0/0"]) + print(exit_code, output) + + # make sure 10.10.10.1 is the correct next hop for default route + assert "10.10.10.1" in output + + # insert default route for table default + dvs.runcmd("ip route add default via 172.17.0.1 table default") + + (exit_code, output) = dvs.runcmd(["redis-cli", "hgetall", "ROUTE_TABLE:0.0.0.0/0"]) + print(exit_code, output) + + time.sleep(10) + # make sure 10.10.10.1 is still the correct next hop for default route + assert "10.10.10.1" in output + + p.terminate() + p = p.wait() + + +