Skip to content

Commit

Permalink
[vstest]: add default vs test
Browse files Browse the repository at this point in the history
Check sonic-net#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 <[email protected]>
  • Loading branch information
lguohan committed Jan 24, 2021
1 parent 46b3bd5 commit b9ccfbe
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions platform/vs/tests/bgp/files/default_route/bgpd.conf
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions platform/vs/tests/bgp/files/default_route/default_route.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
48 changes: 48 additions & 0 deletions platform/vs/tests/bgp/test_default_route.py
Original file line number Diff line number Diff line change
@@ -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()



0 comments on commit b9ccfbe

Please sign in to comment.