Skip to content

Commit

Permalink
test/evpn: add multi-vrf mac-mobility test
Browse files Browse the repository at this point in the history
This test ensures that a MAC can be announced by different peers as long
as it is in different MAC-VRFs, not applying MAC-mobility algorithms.

It does so by adding two additional VRFs for the new route to land in,
and by cleaning up a bit the RDs and RTs used by the existing tests.
  • Loading branch information
Tuetuopay committed Jun 7, 2024
1 parent dace875 commit f7f11a7
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions test/scenario_test/evpn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def setUpClass(cls):

time.sleep(initial_wait_time)
g1.local("gobgp vrf add vrf1 rd 10:10 rt both 10:10")
g2.local("gobgp vrf add vrf1 rd 10:10 rt both 10:10")
g1.local("gobgp vrf add vrf2 rd 10:20 rt both 10:20")
g2.local("gobgp vrf add vrf1 rd 20:10 rt both 10:10")
g2.local("gobgp vrf add vrf2 rd 20:20 rt both 10:20")

for a, b in combinations(ctns, 2):
a.add_peer(b, vpn=True, passwd='evpn')
Expand Down Expand Up @@ -114,7 +116,7 @@ def test_02_add_evpn_route(self):
def test_03_check_mac_mobility(self):
self.g2.local('gobgp global rib add '
'-a evpn macadv 11:22:33:44:55:66 10.0.0.1 esi AS 2 1 1 etag 1000 label 1000 '
'rd 10:20 rt 10:10')
'rd 20:10 rt 10:10')

time.sleep(3)

Expand All @@ -130,7 +132,7 @@ def test_03_check_mac_mobility(self):
def test_04_check_mac_mobility_again(self):
self.g1.local('gobgp global rib add '
'-a evpn macadv 11:22:33:44:55:66 10.0.0.1 esi AS 3 1 1 etag 1000 label 1000 '
'rd 10:20 rt 10:10')
'rd 10:10 rt 10:10')

time.sleep(3)

Expand All @@ -143,6 +145,36 @@ def test_04_check_mac_mobility_again(self):
self.assertTrue(path['nexthop'] in n_addrs)
self.assertEqual(get_mac_mobility_sequence(path['attrs']), 1)

def test_05_check_mac_mobility_per_mac_vrf(self):
self.g2.local('gobgp global rib add '
'-a evpn macadv 11:22:33:44:55:66 10.0.0.1 esi AS 4 1 1 etag 2000 label 2000 '
'rd 20:20 rt 10:20')

time.sleep(3)

grib = self.g2.get_global_rib(rf='evpn')
self.assertEqual(len(grib), 2)
# first route is from previous tests
dst = grib[0]
self.assertEqual(len(dst['paths']), 1)
path = dst['paths'][0]
n_addrs = [i[1].split('/')[0] for i in self.g1.ip_addrs]
self.assertTrue(path['nexthop'] in n_addrs)
self.assertEqual(get_mac_mobility_sequence(path['attrs']), 1)

# dump global rib again on other gobgp instance to have our second route have the nexthop
# filled out. otherwise it'd be 0.0.0.0.
grib = self.g1.get_global_rib(rf='evpn')
self.assertEqual(len(grib), 2)
# second route from this test, in another mac-vrf
dst = grib[1]
self.assertEqual(len(dst['paths']), 1)
path = dst['paths'][0]
n_addrs = [i[1].split('/')[0] for i in self.g2.ip_addrs]
self.assertTrue(path['nexthop'] in n_addrs)
# no mac mobility for this route
self.assertEqual(get_mac_mobility_sequence(path['attrs']), -1)


if __name__ == '__main__':
output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True)
Expand Down

0 comments on commit f7f11a7

Please sign in to comment.