Skip to content

Commit

Permalink
[vs] Stablize test portchannel: test_Portchannel_oper_down end-of-tes…
Browse files Browse the repository at this point in the history
…t cleanup fix (sonic-net#1767)

* Clean up: Remove rif in test_portchannel.py

Signed-off-by: Wenda Ni <wonda.ni@gmail.com>
  • Loading branch information
wendani authored Jun 16, 2021
1 parent 1d19185 commit 6627140
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions tests/test_portchannel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
import re
import json
import pytest
import itertools

from swsscommon import swsscommon
Expand Down Expand Up @@ -214,7 +213,6 @@ def test_Portchannel_oper_down(self, dvs, testlog):
assert len(intf_entries) == 1
assert intf_entries[0] == "40.0.0.6/31"


# set oper_status for PortChannels
ps = swsscommon.ProducerStateTable(self.pdb, "LAG_TABLE")
fvs = swsscommon.FieldValuePairs([("admin_status", "up"),("mtu", "9100"),("oper_status", "up")])
Expand All @@ -234,8 +232,8 @@ def test_Portchannel_oper_down(self, dvs, testlog):
time.sleep(1)

ps = swsscommon.ProducerStateTable(self.pdb, "ROUTE_TABLE")
fvs = swsscommon.FieldValuePairs([("nexthop","40.0.0.1,40.0.0.3,40.0.0.5,40.0.0.7"), ("ifname", "PortChannel001,PortChannel002,PortChannel003,PortChannel004")])

fvs = swsscommon.FieldValuePairs([("nexthop","40.0.0.1,40.0.0.3,40.0.0.5,40.0.0.7"),
("ifname", "PortChannel001,PortChannel002,PortChannel003,PortChannel004")])
ps.set("2.2.2.0/24", fvs)
time.sleep(1)

Expand Down Expand Up @@ -284,6 +282,11 @@ def test_Portchannel_oper_down(self, dvs, testlog):
keys = nhg_member_tbl.getKeys()
assert len(keys) == 3

# remove route entry
ps = swsscommon.ProducerStateTable(self.pdb, "ROUTE_TABLE")
ps._del("2.2.2.0/24")
time.sleep(1)

# remove IP address
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_INTERFACE")
tbl._del("PortChannel001|40.0.0.0/31")
Expand All @@ -309,6 +312,19 @@ def test_Portchannel_oper_down(self, dvs, testlog):
intf_entries = tbl.getKeys()
assert len(intf_entries) == 0

# remove router interfaces
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_INTERFACE")
tbl._del("PortChannel001")
tbl._del("PortChannel002")
tbl._del("PortChannel003")
tbl._del("PortChannel004")
time.sleep(1)

# check application database
tbl = swsscommon.Table(self.pdb, "INTF_TABLE")
intf_entries = tbl.getKeys()
assert len(intf_entries) == 0

# remove PortChannel members
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER")
tbl._del("PortChannel001|Ethernet0")
Expand All @@ -329,7 +345,6 @@ def test_Portchannel_oper_down(self, dvs, testlog):
dvs.servers[0].runcmd("ip link set up dev eth0")
time.sleep(1)

@pytest.mark.skip(reason="This test is not stable enough")
def test_Portchannel_tpid(self, dvs, testlog):
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0)
Expand Down

0 comments on commit 6627140

Please sign in to comment.