Skip to content

Commit

Permalink
What I did:
Browse files Browse the repository at this point in the history
Implemented recursive nexthop group enhancement in Orchagent (NhgOrch).
They have been proposed in:
sonic-net/SONiC#1636

Why I did it:

These changes are required to handle a new field - "nexthop_group" in the
App DB NEXT_HOP_GROUP_TABLE. Such nexthop groups are called recursive
nexthop groups. This field contains the list of member (singleton) nexthop groups.
Such recursive nexthop groups are represented by NEXT_HOP_GROUP objects.
  • Loading branch information
utpalkantpintoo committed May 5, 2024
1 parent f22ced0 commit d54cd50
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions tests/test_nhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,22 +1550,6 @@ def create_route_inexistent_nhg_test():
self.asic_db.wait_for_n_keys(self.ASIC_NHGM_STR, self.asic_nhgms_count)

def test_nhgorch_nh_group(self, dvs, testlog):
# Test scenario:
# - create NHG 'group1' and assert it is being added to ASIC DB along with its members
def create_nhg_test():
# create next hop group in APPL DB
fvs = swsscommon.FieldValuePairs([('nexthop', '10.0.0.1,10.0.0.3,10.0.0.5'),
("ifname", "Ethernet0,Ethernet4,Ethernet8")])
self.nhg_ps.set("group1", fvs)

# check if group was propagated to ASIC DB
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 1)
assert self.nhg_exists('group1')

# check if members were propagated to ASIC DB
self.asic_db.wait_for_n_keys(self.ASIC_NHGM_STR, self.asic_nhgms_count + 3)
assert len(self.get_nhgm_ids('group1')) == 3

# Test scenario:
# - create recursive nhg - rec_grp1 with two members - grp1 and grp2 only one of which exists
# - create singleton nhg grp2 and check if the rec_grp1 is updated with both the members
Expand Down Expand Up @@ -1617,7 +1601,7 @@ def create_recursive_nhg_test():

# check that the group was not propagated to ASIC DB
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 1)
assert self.nhg_exists('rec_grp2')
assert not self.nhg_exists('rec_grp2')

self.nhg_ps._del("rec_grp2")
self.nhg_ps._del("rec_grp1")
Expand All @@ -1627,6 +1611,22 @@ def create_recursive_nhg_test():
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count)
self.asic_db.wait_for_n_keys(self.ASIC_NHGM_STR, self.asic_nhgms_count)

# Test scenario:
# - create NHG 'group1' and assert it is being added to ASIC DB along with its members
def create_nhg_test():
# create next hop group in APPL DB
fvs = swsscommon.FieldValuePairs([('nexthop', '10.0.0.1,10.0.0.3,10.0.0.5'),
("ifname", "Ethernet0,Ethernet4,Ethernet8")])
self.nhg_ps.set("group1", fvs)

# check if group was propagated to ASIC DB
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 1)
assert self.nhg_exists('group1')

# check if members were propagated to ASIC DB
self.asic_db.wait_for_n_keys(self.ASIC_NHGM_STR, self.asic_nhgms_count + 3)
assert len(self.get_nhgm_ids('group1')) == 3

# Test scenario:
# - create a route pointing to `group1` and assert it is being added to ASIC DB and pointing to its SAI ID
# - delete the route and assert it is being removed
Expand Down Expand Up @@ -1781,6 +1781,7 @@ def update_nhgm_count_test():

self.init_test(dvs, 4)

create_recursive_nhg_test()
create_nhg_test()
create_route_nhg_test()
link_flap_test()
Expand Down

0 comments on commit d54cd50

Please sign in to comment.