Skip to content

Commit 1fdcec6

Browse files
authored
fix intermitent failures in test_crm (sonic-net#563)
add acl table created by dtel to acl default tables
1 parent 7724382 commit 1fdcec6

File tree

4 files changed

+21
-58
lines changed

4 files changed

+21
-58
lines changed

tests/conftest.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,7 @@ def __init__(self, dvs):
5151
keys = atbl.getKeys()
5252

5353
assert len(keys) >= 1
54-
55-
# Filter out DTel Acl tables
56-
default_table_found = False
57-
for k in keys:
58-
if default_table_found:
59-
break
60-
(status, fvs) = atbl.get(k)
61-
for item in fvs:
62-
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
63-
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1]:
64-
self.default_acl_table = k
65-
default_table_found = True
66-
break
67-
else:
68-
break
54+
self.default_acl_tables = keys
6955

7056
atbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_ENTRY")
7157
keys = atbl.getKeys()

tests/test_acl.py

+12-26
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,23 @@ class TestAcl(object):
77
def get_acl_table_id(self, dvs, adb):
88
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
99
keys = atbl.getKeys()
10-
assert dvs.asicdb.default_acl_table in keys
11-
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_table]
10+
for k in dvs.asicdb.default_acl_tables:
11+
assert k in keys
12+
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_tables]
1213

13-
assert len(acl_tables) >= 1
14+
assert len(acl_tables) == 1
1415

15-
# Filter out DTel Acl tables
16-
for k in acl_tables:
17-
(status, fvs) = atbl.get(k)
18-
for item in fvs:
19-
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
20-
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1] or 'SAI_ACL_BIND_POINT_TYPE_LAG' in item[1]:
21-
return k
22-
else:
23-
break
24-
25-
return None
16+
return acl_tables[0]
2617

2718
def verify_if_any_acl_table_created(self, dvs, adb):
2819
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
2920
keys = atbl.getKeys()
30-
assert dvs.asicdb.default_acl_table in keys
31-
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_table]
32-
33-
# Filter out DTel Acl tables
34-
for k in acl_tables:
35-
(status, fvs) = atbl.get(k)
36-
for item in fvs:
37-
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
38-
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1] or 'SAI_ACL_BIND_POINT_TYPE_LAG' in item[1]:
39-
return True
40-
else:
41-
break
21+
for k in dvs.asicdb.default_acl_tables:
22+
assert k in keys
23+
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_tables]
24+
25+
if len(acl_tables) != 0:
26+
return True
4227

4328
return False
4429

@@ -158,6 +143,7 @@ def test_AclTableCreation(self, dvs):
158143

159144
# check acl table in asic db
160145
test_acl_table_id = self.get_acl_table_id(dvs, adb)
146+
assert test_acl_table_id
161147

162148
# check acl table group in asic db
163149
self.verify_acl_group_num(adb, 2)

tests/test_crm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def test_CrmAcl(dvs):
499499

500500
# get ACL table key
501501
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
502-
acl_tables = [k for k in atbl.getKeys() if k not in dvs.asicdb.default_acl_table]
502+
acl_tables = [k for k in atbl.getKeys() if k not in dvs.asicdb.default_acl_tables]
503503
key = "ACL_TABLE_STATS:{0}".format(acl_tables[0].replace('oid:', ''))
504504

505505
entry_used_counter = getCrmCounterValue(dvs, key, 'crm_stats_acl_entry_used')

tests/test_mirror.py

+7-16
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,13 @@ def get_acl_table_id(self, dvs):
1010
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
1111
tbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
1212
keys = tbl.getKeys()
13-
assert dvs.asicdb.default_acl_table in keys
14-
15-
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_table]
16-
assert len(acl_tables) >= 1
17-
18-
# Filter out DTel Acl tables
19-
for k in acl_tables:
20-
(status, fvs) = tbl.get(k)
21-
for item in fvs:
22-
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
23-
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1] or 'SAI_ACL_BIND_POINT_TYPE_LAG' in item[1]:
24-
return k
25-
else:
26-
break
27-
28-
return None
13+
for k in dvs.asicdb.default_acl_tables:
14+
assert k in keys
15+
16+
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_tables]
17+
assert len(acl_tables) == 1
18+
19+
return acl_tables[0]
2920

3021
def get_mirror_session_id(self, dvs):
3122
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)

0 commit comments

Comments
 (0)