Skip to content

Commit

Permalink
added a test to check if same route added on 2 T1 gets propogated to …
Browse files Browse the repository at this point in the history
…the TOR (sonic-net#14683)

Description of PR
Summary:
Fixes # (issue)
sonic-net#10837

Orignal Problem
In multipath scenario when a route is advertised through network command from two neighbors, only one path is chosen. Doing clear bgp * recovers the device from this scenario.

If the same route (be it default or non-default) is advertised from two leaf to a ToR, the leaf initially shows only one leaf's links as next hop. When we do clear bgp *, it is then updated.

B>* 20.0.0.1/32 [20/0] via 192.168.1.2, PortChannel1, weight 1, 00:16:52

               via 192.168.2.2, PortChannel2, weight 1, 00:16:52
               via 192.168.3.2, PortChannel3, weight 1, 00:16:52
               via 192.168.4.2, PortChannel4, weight 1, 00:16:52
After doing clear bgp * in tgn-sonic-n2-t1 I can see this

B>* 20.0.0.1/32 [20/0] via 192.168.1.2, PortChannel1, weight 1, 00:00:02

               via 192.168.2.2, PortChannel2, weight 1, 00:00:02
               via 192.168.3.2, PortChannel3, weight 1, 00:00:02
               via 192.168.4.2, PortChannel4, weight 1, 00:00:02
               via 192.168.5.2, PortChannel5, weight 1, 00:00:02
               via 192.168.6.2, PortChannel6, weight 1, 00:00:02
               via 192.168.8.2, PortChannel8, weight 1, 00:00:02

This issue was fixed in PR sonic-net/sonic-buildimage#17184
However a test for this was missing.
so this test adds a prefix on 2 T1 neighbors using network command and checks if the advertised route is learnt on the T0 DUT
  • Loading branch information
siqbal1986 authored Oct 23, 2024
1 parent ca9bd9b commit d24042b
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
78 changes: 78 additions & 0 deletions tests/bgp/test_bgp_route_neigh_learning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import pytest
import logging
from tests.common.helpers.assertions import pytest_assert as py_assert
pytestmark = [
pytest.mark.topology('t0'),
pytest.mark.device_type('vs')
]

Logger = logging.getLogger(__name__)

V4_PREFIX = "77.88.99.1"
V4_MASK = "32"


@pytest.fixture(name="setUp", scope="module")
def fixture_setUp(nbrhosts):
'''
This fixture setup filters the T1 neigbor names from the nbrhosts. and T the end cleans up the routes
from the T1 neighbors.
'''
data = {}
data['nbr'] = nbrhosts
data['T1'] = []
nbrnames = list(nbrhosts.keys())
count = 2
for name in nbrnames:
if 'T1' in name:
data['T1'].append(name)
count -= 1
if count == 0:
break
yield data

Logger.info("Performing cleanup")
for name in data['T1']:
# remove the route in the neighbor T1 eos device
cmds = ["configure",
"router bgp 64600",
"address-family ipv4",
"no network {}/{}".format(V4_PREFIX, V4_MASK),
"no interface loopback 1",
"exit"
]
Logger.info("Route, IP and Loopback 1 remvoed from %s", name)
data['nbr'][name]['host'].run_command_list(cmds)


def run_bgp_neighbor_route_learning(duthosts, enum_frontend_dut_hostname, data):
""" Route added on All neighbor should be learned by the DUT"""
Logger.info("Adding routes on neighbors")

for name in data['T1']:
# add a route in the neighbor T1 eos device
cmds = ["configure",
"interface loopback 1",
"ip address {}/{}".format(V4_PREFIX, V4_MASK),
"exit",
"router bgp 64600",
"address-family ipv4",
"network {}/{}".format(V4_PREFIX, V4_MASK),
"exit"
]
data['nbr'][name]['host'].run_command_list(cmds)
Logger.info("Route %s added to :%s", V4_PREFIX, name)

duthost = duthosts[enum_frontend_dut_hostname]
# redis-cli -n 0 hget "ROUTE_TABLE:99.99.99.99" 'nexthop'
Logger.info("checking DUT for route %s", V4_PREFIX)
cmd = "redis-cli -n 0 hget \"ROUTE_TABLE:{}\" 'nexthop'".format(V4_PREFIX)
result = duthost.shell(cmd)
result = result['stdout']
Logger.info("Route table nexthops are %s", result)
py_assert(result != "", "The route has not propogated to the DUT")
py_assert(len(result.split(",")) == len(data['T1']), "Some Neighbor did not propogate route to the DUT")


def test_bgp_neighbor_route_learnning(duthosts, enum_frontend_dut_hostname, setUp):
run_bgp_neighbor_route_learning(duthosts, enum_frontend_dut_hostname, setUp)
3 changes: 3 additions & 0 deletions tests/common/devices/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ def get_route(self, prefix):
'output': 'json'
}])['stdout'][0]

def run_command_list(self, cmd):
return self.eos_command(commands=cmd)

def get_auto_negotiation_mode(self, interface_name):
output = self.eos_command(commands=[{
'command': 'show interfaces %s status' % interface_name,
Expand Down

0 comments on commit d24042b

Please sign in to comment.