Skip to content

Commit

Permalink
Fix and more UT
Browse files Browse the repository at this point in the history
  • Loading branch information
TACappleman committed Nov 13, 2021
1 parent 9cff811 commit 9ab2522
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
7 changes: 3 additions & 4 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ orchagent_SOURCES = \
orch.cpp \
notifications.cpp \
nhgorch.cpp \
cbf/nhgbase.cpp \
cbf/nhghandler.cpp \
cbf/cbfnhghandler.cpp \
nhgmaporch.cpp \
nhgbase.cpp \
cbf/cbfnhgorch.cpp \
cbf/nhgmaporch.cpp \
routeorch.cpp \
mplsrouteorch.cpp \
neighorch.cpp \
Expand Down
44 changes: 39 additions & 5 deletions tests/test_nhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,17 +1769,17 @@ def update_cbf_nhg_map_test():
def delete_referenced_cbf_nhg_test():
# Create a route pointing to the CBF NHG
fvs = swsscommon.FieldValuePairs([('nexthop_group', 'cbfgroup1')])
self.rt_ps.set('2.2.2.0/24', fvs)
self.asic_db.wait_for_n_keys(self.ASIC_RT_STR, self.asic_rts_count + 1)
self.lr_ps.set('10', fvs)
self.asic_db.wait_for_n_keys(self.ASIC_INSEG_STR, self.asic_insgs_count + 1)

# Try deleting the CBF NHG - should not work
self.cbf_nhg_ps._del('cbfgroup1')
time.sleep(1)
assert(self.nhg_exists('cbfgroup1'))

# Delete the route - the CBF NHG should also get deleted
self.rt_ps._del('2.2.2.0/24')
self.asic_db.wait_for_n_keys(self.ASIC_RT_STR, self.asic_rts_count)
# Delete the label route - the CBF NHG should also get deleted
self.lr_ps._del('10')
self.asic_db.wait_for_n_keys(self.ASIC_INSEG_STR, self.asic_insgs_count)
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 2)
self.asic_db.wait_for_n_keys(self.ASIC_NHGM_STR, self.asic_nhgms_count + 3)

Expand Down Expand Up @@ -1920,8 +1920,21 @@ def test_nhg_map(self, dvs, testlog):

# Test scenario:
# - create a NHG map and assert the expected details
# - update the map
# - delete the map
def mainline_nhg_map_test():
# Create two non-CBF NHGs
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)

fvs = swsscommon.FieldValuePairs([('nexthop', '10.0.0.1,10.0.0.3'),
('ifname', 'Ethernet0,Ethernet4')])
self.nhg_ps.set('group2', fvs)

# Wait for the groups to appear in ASIC DB
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 2)

# Create an FC to NH index map
fvs = swsscommon.FieldValuePairs([('0', '0')])
self.fc_to_nhg_ps.set('cbfnhgmap1', fvs)
Expand All @@ -1936,6 +1949,27 @@ def mainline_nhg_map_test():
{'SAI_NEXT_HOP_GROUP_MAP_ATTR_TYPE': 'SAI_NEXT_HOP_GROUP_MAP_TYPE_FORWARDING_CLASS_TO_INDEX',
'SAI_NEXT_HOP_GROUP_MAP_ATTR_MAP_TO_VALUE_LIST': '{\"count\":1,\"list\":[{\"key\":0,\"value\":0}]}'})

# Create a CBF next hop group
fvs = swsscommon.FieldValuePairs([('members', 'group1,group2'),
('selection_map', 'cbfnhgmap1')])
self.cbf_nhg_ps.set('cbfgroup1', fvs)
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 3)

# Update the map.
fvs = swsscommon.FieldValuePairs([('0', '0'), ('1', '1')])
self.fc_to_nhg_ps.set('cbfnhgmap1', fvs)

self.asic_db.wait_for_field_match(self.ASIC_NHG_MAP_STR,
nhg_map_id,
{'SAI_NEXT_HOP_GROUP_MAP_ATTR_TYPE': 'SAI_NEXT_HOP_GROUP_MAP_TYPE_FORWARDING_CLASS_TO_INDEX',
'SAI_NEXT_HOP_GROUP_MAP_ATTR_MAP_TO_VALUE_LIST': '{\"count\":2,\"list\":[{\"key\":1,\"value\":1},{\"key\":0,\"value\":0}]}'})

# Delete the group
self.cbf_nhg_ps._del('cbfgroup1')
self.nhg_ps._del("group1")
self.nhg_ps._del("group2")
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count)

# Delete the map
self.fc_to_nhg_ps._del('cbfnhgmap1')
self.asic_db.wait_for_n_keys(self.ASIC_NHG_MAP_STR, self.asic_nhg_maps_count)
Expand Down

0 comments on commit 9ab2522

Please sign in to comment.