From 29fe875a1c89630f5c78b2ac6ba35eec02904637 Mon Sep 17 00:00:00 2001 From: "david.zagury" Date: Tue, 2 Mar 2021 14:14:26 +0200 Subject: [PATCH] [VStest] Add test that checks LACP key is the expected LACP key --- cfgmgr/teammgr.cpp | 7 ------ tests/test_portchannel.py | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/cfgmgr/teammgr.cpp b/cfgmgr/teammgr.cpp index 7f00b76bbfd..4832b24f0d4 100644 --- a/cfgmgr/teammgr.cpp +++ b/cfgmgr/teammgr.cpp @@ -179,12 +179,6 @@ void TeamMgr::doLagTask(Consumer &consumer) SWSS_LOG_INFO("Get learn_mode %s", learn_mode.c_str()); } - else if (fvField(i) == "lacp_key") - { - lacp_key = fvValue(i); - SWSS_LOG_INFO("Get lacp_key %s", - lacp_key.c_str()); - } } if (m_lagList.find(alias) == m_lagList.end()) @@ -200,7 +194,6 @@ void TeamMgr::doLagTask(Consumer &consumer) setLagAdminStatus(alias, admin_status); setLagMtu(alias, mtu); - setLacpKey(alias, lacp_key); if (!learn_mode.empty()) { setLagLearnMode(alias, learn_mode); diff --git a/tests/test_portchannel.py b/tests/test_portchannel.py index 4e03a81aacd..98d547bbb44 100644 --- a/tests/test_portchannel.py +++ b/tests/test_portchannel.py @@ -89,6 +89,51 @@ def test_Portchannel(self, dvs, testlog): lagms = lagmtbl.getKeys() assert len(lagms) == 0 + def test_Portchannel_lacpkey(self, dvs, testlog): + portchannelNames = [("PortChannel001", "Ethernet0", 1001), + ("PortChannel002", "Ethernet4", 1002), + ("PortChannel2", "Ethernet8", 12), + ("PortChannel000", "Ethernet12", 1000)] + + self.adb = swsscommon.DBConnector(1, dvs.redis_sock, 0) + self.cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0) + self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0) + + # Create 4 PortChannels + tbl = swsscommon.Table(self.cdb, "PORTCHANNEL") + fvs = swsscommon.FieldValuePairs( + [("admin_status", "up"), ("mtu", "9100"), ("oper_status", "up"), ("lacp_key", "auto")]) + + for portchannel in portchannelNames: + tbl.set(portchannel[0], fvs) + time.sleep(1) + + tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER") + fvs = swsscommon.FieldValuePairs([("NULL", "NULL")]) + + for portchannel in portchannelNames: + tbl.set(portchannel[0] + "|" + portchannel[1], fvs) + time.sleep(1) + + # TESTS here that LACP key is valid and equls to the expected LACP key + # The expected LACP key in the number at the end of the Port-Channel name with a prefix '1' + for portchannel in portchannelNames: + (exit_code, output) = dvs.runcmd("teamdctl " + portchannel[0] + " state dump") + port_state_dump = json.loads(output) + lacp_key = port_state_dump["ports"][portchannel[1]]["runner"]["actor_lacpdu_info"]["key"] + assert lacp_key == portchannel[2] + + # remove PortChannel members + tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER") + for portchannel in portchannelNames: + tbl._del(portchannel[0] + "|" + portchannel[1]) + time.sleep(1) + + # remove PortChannel + tbl = swsscommon.Table(self.cdb, "PORTCHANNEL") + for portchannel in portchannelNames: + tbl._del(portchannel[0]) + time.sleep(1) def test_Portchannel_oper_down(self, dvs, testlog):