[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 <lguohan@gmail.com>
This commit is contained in:
Guohan Lu 2021-01-24 14:40:43 -08:00 committed by lguohan
parent cd3ed549c3
commit 4b5212b8b2
3 changed files with 69 additions and 0 deletions

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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()