Skip to content

Commit 1cfa47a

Browse files
author
novikauanton
authored
Merge branch 'Azure:master' into feature/teamd-configure-lacp-rate
2 parents 61e3cdd + adcf69d commit 1cfa47a

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

orchagent/cbf/cbfnhgorch.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,11 @@ bool CbfNhg::syncMembers(const set<string> &members)
632632
nhgm.to_string().c_str(), to_string().c_str());
633633
throw std::logic_error("Syncing already synced NHG member");
634634
}
635+
else if (nhgm.getNhgId() == SAI_NULL_OBJECT_ID)
636+
{
637+
SWSS_LOG_WARN("CBF NHG member %s is not yet synced", nhgm.to_string().c_str());
638+
return false;
639+
}
635640

636641
/*
637642
* Check if the group exists in NhgOrch.
@@ -710,10 +715,9 @@ vector<sai_attribute_t> CbfNhg::createNhgmAttrs(const CbfNhgMember &nhgm) const
710715
{
711716
SWSS_LOG_ENTER();
712717

713-
if (!isSynced() || (nhgm.getNhgId() == SAI_NULL_OBJECT_ID))
718+
if (!isSynced())
714719
{
715-
SWSS_LOG_ERROR("CBF next hop group %s or next hop group %s are not synced",
716-
to_string().c_str(), nhgm.to_string().c_str());
720+
SWSS_LOG_ERROR("CBF next hop group %s is not synced", to_string().c_str());
717721
throw logic_error("CBF next hop group member attributes data is insufficient");
718722
}
719723

tests/test_nhg.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,42 @@ def create_cbf_nhg_inexistent_map_test():
22072207
self.fc_to_nhg_ps._del(nhg_maps.pop())
22082208
self.asic_db.wait_for_n_keys(self.ASIC_NHG_MAP_STR, self.asic_nhg_maps_count)
22092209

2210+
# Test scenario:
2211+
# - Create a CBF NHG that has a member which is not yet synced. It shouldn't be synced.
2212+
# - Add the missing member and assert the CBF NHG is now synced.
2213+
def test_cbf_sync_before_member(self, dvs, testlog):
2214+
self.init_test(dvs, 2)
2215+
2216+
# Create an FC to NH index selection map
2217+
nhg_map = [(str(i), '0' if i < 4 else '1') for i in range(8)]
2218+
fvs = swsscommon.FieldValuePairs(nhg_map)
2219+
self.fc_to_nhg_ps.set('cbfnhgmap1', fvs)
2220+
self.asic_db.wait_for_n_keys(self.ASIC_NHG_MAP_STR, self.asic_nhg_maps_count + 1)
2221+
2222+
# Create a non-CBF NHG
2223+
fvs = swsscommon.FieldValuePairs([('nexthop', '10.0.0.1,10.0.0.3'),
2224+
('ifname', 'Ethernet0,Ethernet4')])
2225+
self.nhg_ps.set('group1', fvs)
2226+
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 1)
2227+
2228+
# Create a CBF NHG with a member that doesn't currently exist. Nothing should happen
2229+
fvs = swsscommon.FieldValuePairs([('members', 'group1,group2'),
2230+
('selection_map', 'cbfnhgmap1')])
2231+
self.cbf_nhg_ps.set('cbfgroup1', fvs)
2232+
time.sleep(1)
2233+
assert(len(self.asic_db.get_keys(self.ASIC_NHG_STR)) == self.asic_nhgs_count + 1)
2234+
2235+
# Create the missing non-CBF NHG. This and the CBF NHG should be created.
2236+
fvs = swsscommon.FieldValuePairs([('nexthop', '10.0.0.1,10.0.0.3'),
2237+
("ifname", "Ethernet0,Ethernet4")])
2238+
self.nhg_ps.set("group2", fvs)
2239+
self.asic_db.wait_for_n_keys(self.ASIC_NHG_STR, self.asic_nhgs_count + 3)
2240+
2241+
# Cleanup
2242+
self.nhg_ps._del('cbfgroup1')
2243+
self.nhg_ps._del('group1')
2244+
self.nhg_ps._del('group2')
2245+
self.nhg_ps._del('cbfnhgmap1')
22102246

22112247
# Add Dummy always-pass test at end as workaroud
22122248
# for issue when Flaky fail on final test it invokes module tear-down before retrying

0 commit comments

Comments
 (0)