Skip to content

Commit 84415f6

Browse files
daalllguohan
authored andcommitted
[vs tests] Activate flaky plugin for virtual switch pytests (#1186)
Signed-off-by: Danny Allen <[email protected]>
1 parent 5eb1ea3 commit 84415f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+219
-64
lines changed

tests/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ SWSS Integration tests runs on docker-sonic-vs which runs on top of SAI virtual
88

99
- Install docker and pytest on your dev machine
1010
```
11-
sudo pip install --system docker==3.5.0
12-
sudo pip install --system pytest==3.3.0 docker redis
11+
sudo pip install docker==3.5.0
12+
sudo pip install pytest==3.3.0
13+
sudo pip install flaky docker redis
1314
```
1415
- Compile and install swss common library. Follow instructions [here](https://github.com/Azure/sonic-swss-common/blob/master/README.md) to first install prerequisites to build swss common library.
1516
```

tests/test_acl.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from swsscommon import swsscommon
21
import time
32
import re
43
import json
4+
import pytest
5+
6+
from swsscommon import swsscommon
7+
from flaky import flaky
58

69

710
class BaseTestAcl(object):
@@ -185,6 +188,7 @@ def verify_acl_rule(self, dvs, field, value):
185188
assert False
186189

187190

191+
@pytest.mark.flaky
188192
class TestAcl(BaseTestAcl):
189193
def test_AclTableCreation(self, dvs, testlog):
190194
self.setup_db(dvs)
@@ -1370,6 +1374,8 @@ def test_AclRuleRedirectToNexthop(self, dvs, testlog):
13701374
# bring down interface
13711375
dvs.set_interface_status("Ethernet4", "down")
13721376

1377+
1378+
@pytest.mark.flaky
13731379
class TestAclRuleValidation(BaseTestAcl):
13741380
""" Test class for cases that check if orchagent corectly validates
13751381
ACL rules input

tests/test_acl_ctrl.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import time
2+
import pytest
3+
14
from swsscommon import swsscommon
5+
from flaky import flaky
26

3-
import time
47

8+
@pytest.mark.flaky
59
class TestPortChannelAcl(object):
610
def setup_db(self, dvs):
711
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_acl_egress_table.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import time
2+
import pytest
3+
14
from swsscommon import swsscommon
5+
from flaky import flaky
26

3-
import time
47

8+
@pytest.mark.flaky
59
class TestEgressAclTable(object):
610
def setup_db(self, dvs):
711
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_acl_portchannel.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import time
2+
import pytest
3+
14
from swsscommon import swsscommon
5+
from flaky import flaky
26

3-
import time
47

8+
@pytest.mark.flaky
59
class TestPortChannelAcl(object):
610
def setup_db(self, dvs):
711
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_admin_status.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from swsscommon import swsscommon
21
import time
2+
import pytest
3+
4+
from swsscommon import swsscommon
5+
from flaky import flaky
6+
37

8+
@pytest.mark.flaky
49
class TestAdminStatus(object):
510
def setup_db(self, dvs):
611
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_crm.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from swsscommon import swsscommon
21
import os
32
import re
43
import time
54
import json
65
import redis
6+
import pytest
77

8+
from swsscommon import swsscommon
9+
from flaky import flaky
810

911
def getCrmCounterValue(dvs, key, counter):
1012

@@ -62,6 +64,8 @@ def check_syslog(dvs, marker, err_log, expected_cnt):
6264
(exitcode, num) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \"%s\" | wc -l" % (marker, err_log)])
6365
assert num.strip() >= str(expected_cnt)
6466

67+
68+
@pytest.mark.flaky
6569
class TestCrm(object):
6670
def test_CrmFdbEntry(self, dvs, testlog):
6771

tests/test_dirbcast.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
from swsscommon import swsscommon
21
import time
32
import re
43
import json
4+
import pytest
5+
6+
from swsscommon import swsscommon
7+
from flaky import flaky
8+
59

10+
@pytest.mark.flaky
611
class TestDirectedBroadcast(object):
712
def test_DirectedBroadcast(self, dvs, testlog):
813

tests/test_drop_counters.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from swsscommon import swsscommon
2-
31
import time
2+
import pytest
3+
4+
from swsscommon import swsscommon
5+
from flaky import flaky
46

57
# Supported drop counters
68
PORT_INGRESS_DROPS = 'PORT_INGRESS_DROPS'
@@ -53,9 +55,11 @@
5355
EXPECTED_ASIC_FIELDS = [ASIC_COUNTER_TYPE_FIELD, ASIC_COUNTER_INGRESS_REASON_LIST_FIELD, ASIC_COUNTER_EGRESS_REASON_LIST_FIELD]
5456
EXPECTED_NUM_ASIC_FIELDS = 2
5557

58+
5659
# FIXME: It is really annoying to have to re-run tests due to inconsistent timing, should
5760
# implement some sort of polling interface for checking ASIC/flex counter tables after
5861
# applying changes to config DB
62+
@pytest.mark.flaky
5963
class TestDropCounters(object):
6064
def setup_db(self, dvs):
6165
self.asic_db = swsscommon.DBConnector(1, dvs.redis_sock, 0)

tests/test_dtel.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
from swsscommon import swsscommon
2-
3-
41
import time
52
import re
63
import json
4+
import pytest
5+
6+
from swsscommon import swsscommon
7+
from flaky import flaky
78

9+
10+
@pytest.mark.flaky
811
class TestDtel(object):
912
def test_DtelGlobalAttribs(self, dvs, testlog):
10-
13+
1114
db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
1215
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
13-
16+
1417
# create DTel global attributes in config db
1518
tbl = swsscommon.Table(db, "DTEL")
1619

tests/test_fdb.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from swsscommon import swsscommon
21
import os
32
import sys
43
import time
54
import json
5+
import pytest
6+
7+
from swsscommon import swsscommon
8+
from flaky import flaky
69
from distutils.version import StrictVersion
710

811
def create_entry(tbl, key, pairs):
@@ -24,6 +27,8 @@ def how_many_entries_exist(db, table):
2427
tbl = swsscommon.Table(db, table)
2528
return len(tbl.getKeys())
2629

30+
31+
@pytest.mark.flaky
2732
class TestFdb(object):
2833
def test_FdbWarmRestartNotifications(self, dvs, testlog):
2934
dvs.setup_db()

tests/test_fdb_update.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
from swsscommon import swsscommon
21
import os
32
import sys
43
import time
54
import json
5+
import pytest
6+
7+
from swsscommon import swsscommon
8+
from flaky import flaky
69
from distutils.version import StrictVersion
710

811

12+
@pytest.mark.flaky
913
class TestFdbUpdate(object):
1014
def create_entry(self, tbl, key, pairs):
1115
fvs = swsscommon.FieldValuePairs(pairs)

tests/test_interface.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
from swsscommon import swsscommon
2-
31
import time
42
import json
3+
import pytest
4+
5+
from swsscommon import swsscommon
6+
from flaky import flaky
7+
58

9+
@pytest.mark.flaky
610
class TestRouterInterface(object):
711
def setup_db(self, dvs):
812
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_mirror.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# This test suite covers the functionality of mirror feature in SwSS
2-
32
import platform
43
import pytest
54
import time
6-
from distutils.version import StrictVersion
75

86
from swsscommon import swsscommon
7+
from flaky import flaky
8+
from distutils.version import StrictVersion
99

1010

11+
@pytest.mark.flaky
1112
class TestMirror(object):
1213
def setup_db(self, dvs):
1314
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_mirror_ipv6_combined.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# This test suite covers the functionality of mirror feature in SwSS
2-
32
import platform
43
import pytest
54
import time
6-
from distutils.version import StrictVersion
75

86
from swsscommon import swsscommon
7+
from flaky import flaky
8+
from distutils.version import StrictVersion
99

1010
DVS_FAKE_PLATFORM = "broadcom"
1111

1212

13+
@pytest.mark.flaky
1314
class TestMirror(object):
1415
def setup_db(self, dvs):
1516
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_mirror_ipv6_separate.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# This test suite covers the functionality of mirror feature in SwSS
2-
32
import platform
43
import pytest
54
import time
65
from distutils.version import StrictVersion
76

87
from swsscommon import swsscommon
8+
from flaky import flaky
99

1010
DVS_FAKE_PLATFORM = "mellanox"
1111

1212

13+
@pytest.mark.flaky
1314
class TestMirror(object):
1415
def setup_db(self, dvs):
1516
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_mirror_policer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# This test suite covers the functionality of mirror feature in SwSS
2-
32
import platform
43
import pytest
54
import time
6-
from distutils.version import StrictVersion
75

86
from swsscommon import swsscommon
7+
from flaky import flaky
8+
from distutils.version import StrictVersion
99

1010

11+
@pytest.mark.flaky
1112
class TestMirror(object):
1213
def setup_db(self, dvs):
1314
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_nat.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
from swsscommon import swsscommon
21
import time
32
import re
43
import json
54
import pytest
65
import pdb
76
import os
87

8+
from swsscommon import swsscommon
9+
from flaky import flaky
10+
11+
912
# FIXME: These tests depend on changes in sonic-buildimage, we need to reenable
1013
# them once those changes are merged.
1114
@pytest.mark.skip(reason="Depends on changes in sonic-buildimage")

tests/test_neighbor.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
from swsscommon import swsscommon
2-
31
import time
42
import json
3+
import pytest
4+
5+
from swsscommon import swsscommon
6+
from flaky import flaky
7+
58

9+
@pytest.mark.flaky
610
class TestNeighbor(object):
711
def setup_db(self, dvs):
812
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tests/test_nhg.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
from swsscommon import swsscommon
21
import os
32
import re
43
import time
54
import json
5+
import pytest
6+
7+
from swsscommon import swsscommon
8+
from flaky import flaky
9+
610

11+
@pytest.mark.flaky
712
class TestNextHopGroup(object):
813
def test_route_nhg(self, dvs, testlog):
914
config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0)

tests/test_pfc.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import time
2-
from swsscommon import swsscommon
2+
import pytest
33

4+
from swsscommon import swsscommon
5+
from flaky import flaky
46

57
def getBitMaskStr(bits):
68

@@ -57,6 +59,8 @@ def getPortAttr(dvs, port_oid, port_attr):
5759

5860
return ''
5961

62+
63+
@pytest.mark.flaky
6064
class TestPfc(object):
6165
def test_PfcAsymmetric(self, dvs, testlog):
6266

tests/test_policer.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import time
44

55
from swsscommon import swsscommon
6+
from flaky import flaky
67

8+
9+
@pytest.mark.flaky
710
class TestPolicer(object):
811
def test_PolicerBasic(self, dvs, testlog):
912
dvs.setup_db()

tests/test_port.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
from swsscommon import swsscommon
2-
31
import time
42
import os
3+
import pytest
4+
5+
from swsscommon import swsscommon
6+
from flaky import flaky
7+
58

9+
@pytest.mark.flaky
610
class TestPort(object):
711
def test_PortMtu(self, dvs, testlog):
812
pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)

0 commit comments

Comments
 (0)