Skip to content

Commit

Permalink
[dvs] Fix unstable DPB and NAT test cases (sonic-net#1408)
Browse files Browse the repository at this point in the history
- Re-enable test_port_dpb
- Add polling to NAT

Signed-off-by: Danny Allen <[email protected]>
  • Loading branch information
daall authored Aug 24, 2020
1 parent c4949a2 commit e6fda33
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
45 changes: 22 additions & 23 deletions tests/test_nat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import time
import pytest

from dvslib.dvs_common import wait_for_result
from dvslib.dvs_database import DVSDatabase


class TestNat(object):
def setup_db(self, dvs):
self.app_db = dvs.get_app_db()
Expand Down Expand Up @@ -279,47 +283,42 @@ def test_DelTwiceNaPtStaticEntry(self, dvs, testlog):
# clear interfaces
self.clear_interfaces(dvs)

@pytest.mark.xfail(reason="Test unstable, blocking PR builds")
@pytest.mark.skip("Issue #1409")
def test_VerifyConntrackTimeoutForNatEntry(self, dvs, testlog):
# initialize
self.setup_db(dvs)

# get neighbor and arp entry
dvs.servers[0].runcmd("ping -c 1 18.18.18.2")

# add a static nat entry
dvs.runcmd("config nat add static basic 67.66.65.1 18.18.18.2")

# check the conntrack timeout for static entry
output = dvs.runcmd("conntrack -j -L -s 18.18.18.2 -p udp -q 67.66.65.1")
assert len(output) == 2
def _check_conntrack_for_static_entry():
output = dvs.runcmd("conntrack -j -L -s 18.18.18.2 -p udp -q 67.66.65.1")
if len(output) != 2:
return (False, None)

conntrack_list = list(output[1].split(" "))

conntrack_list = list(output[1].split(" "))
src_exists = "src=18.18.18.2" in conntrack_list
dst_exists = "dst=67.66.65.1" in conntrack_list
proto_exists = "udp" in conntrack_list

src_exists = dst_exists = proto_exists = False
proto_index = 0
if not src_exists or not dst_exists or not proto_exists:
return (False, None)

for i in conntrack_list:
if i == "src=18.18.18.2":
src_exists = True
elif i == "dst=67.66.65.1":
dst_exists = True
elif i == "udp":
proto_exists = True
proto_index = conntrack_list.index(i)
proto_index = conntrack_list.index("udp")

assert src_exists == True
assert dst_exists == True
assert proto_exists == True
# FIXME: conntrack_list[proto_index + 7] is consistently returning 431995. Need the feature owner
# to confirm if this check is wrong or if the behavior is wrong.
if int(conntrack_list[proto_index + 7]) < 432000 and int(conntrack_list[proto_index + 7]) > 431900:
return (False, None)

if conntrack_list[proto_index + 7] < 432000 and conntrack_list[proto_index + 7] > 431900:
assert False
wait_for_result(_check_conntrack_for_static_entry, DVSDatabase.DEFAULT_POLLING_CONFIG)

# delete a static nat entry
dvs.runcmd("config nat remove static basic 67.66.65.1 18.18.18.2")



# Add Dummy always-pass test at end as workaroud
# for issue when Flaky fail on final test it invokes module tear-down before retrying
def test_nonflaky_dummy():
Expand Down
9 changes: 1 addition & 8 deletions tests/test_port_dpb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class TestPortDPB(object):
Empty --> Not Tested
'''

'''
@pytest.mark.skip()
'''
def test_port_breakout_one(self, dvs):
dpb = DPB()
dpb.breakout(dvs, "Ethernet0", maxBreakOut)
Expand Down Expand Up @@ -70,10 +67,6 @@ def test_port_breakout_one(self, dvs):
dpb.change_speed_and_verify(dvs, ["Ethernet0"], speed40G)
#print "**** 1X100G --> 1X40G passed ****"

'''
@pytest.mark.skip()
'''
@pytest.mark.xfail(reason="test stability issue: Azure/sonic-swss#1222")
def test_port_breakout_multiple(self, dvs):
dpb = DPB()
port_names = ["Ethernet0", "Ethernet12", "Ethernet64", "Ethernet112"]
Expand All @@ -84,7 +77,7 @@ def test_port_breakout_multiple(self, dvs):
dpb.breakin(dvs, ["Ethernet64", "Ethernet65", "Ethernet66", "Ethernet67"])
dpb.breakin(dvs, ["Ethernet112", "Ethernet113", "Ethernet114", "Ethernet115"])

@pytest.mark.skip()
@pytest.mark.skip("breakout_all takes too long to execute")
def test_port_breakout_all(self, dvs):
dpb = DPB()
port_names = []
Expand Down

0 comments on commit e6fda33

Please sign in to comment.