Skip to content

Commit

Permalink
[VStest] Add test that checks LACP key is the expected LACP key
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZagury committed Mar 4, 2021
1 parent fafca38 commit 29fe875
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
7 changes: 0 additions & 7 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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);
Expand Down
45 changes: 45 additions & 0 deletions tests/test_portchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit 29fe875

Please sign in to comment.