From d54cd50286e2c44448b166de1eef4d438644ecdb Mon Sep 17 00:00:00 2001 From: Utpal Pintoo Date: Sun, 5 May 2024 11:30:16 -0700 Subject: [PATCH] What I did: Implemented recursive nexthop group enhancement in Orchagent (NhgOrch). They have been proposed in: https://github.com/sonic-net/SONiC/pull/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. --- tests/test_nhg.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/test_nhg.py b/tests/test_nhg.py index 119b703be1b..b9e125f7609 100644 --- a/tests/test_nhg.py +++ b/tests/test_nhg.py @@ -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 @@ -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") @@ -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 @@ -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()