Skip to content

Commit 6627140

Browse files
authored
[vs] Stablize test portchannel: test_Portchannel_oper_down end-of-test cleanup fix (#1767)
* Clean up: Remove rif in test_portchannel.py Signed-off-by: Wenda Ni <[email protected]>
1 parent 1d19185 commit 6627140

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

tests/test_portchannel.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import time
22
import re
33
import json
4-
import pytest
54
import itertools
65

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

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

236234
ps = swsscommon.ProducerStateTable(self.pdb, "ROUTE_TABLE")
237-
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")])
238-
235+
fvs = swsscommon.FieldValuePairs([("nexthop","40.0.0.1,40.0.0.3,40.0.0.5,40.0.0.7"),
236+
("ifname", "PortChannel001,PortChannel002,PortChannel003,PortChannel004")])
239237
ps.set("2.2.2.0/24", fvs)
240238
time.sleep(1)
241239

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

285+
# remove route entry
286+
ps = swsscommon.ProducerStateTable(self.pdb, "ROUTE_TABLE")
287+
ps._del("2.2.2.0/24")
288+
time.sleep(1)
289+
287290
# remove IP address
288291
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_INTERFACE")
289292
tbl._del("PortChannel001|40.0.0.0/31")
@@ -309,6 +312,19 @@ def test_Portchannel_oper_down(self, dvs, testlog):
309312
intf_entries = tbl.getKeys()
310313
assert len(intf_entries) == 0
311314

315+
# remove router interfaces
316+
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_INTERFACE")
317+
tbl._del("PortChannel001")
318+
tbl._del("PortChannel002")
319+
tbl._del("PortChannel003")
320+
tbl._del("PortChannel004")
321+
time.sleep(1)
322+
323+
# check application database
324+
tbl = swsscommon.Table(self.pdb, "INTF_TABLE")
325+
intf_entries = tbl.getKeys()
326+
assert len(intf_entries) == 0
327+
312328
# remove PortChannel members
313329
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER")
314330
tbl._del("PortChannel001|Ethernet0")
@@ -329,7 +345,6 @@ def test_Portchannel_oper_down(self, dvs, testlog):
329345
dvs.servers[0].runcmd("ip link set up dev eth0")
330346
time.sleep(1)
331347

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

0 commit comments

Comments
 (0)