Skip to content

Commit

Permalink
fix intermitent failures in test_crm (sonic-net#563)
Browse files Browse the repository at this point in the history
add acl table created by dtel to acl default tables
  • Loading branch information
lguohan authored Aug 3, 2018
1 parent 7724382 commit 1fdcec6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 58 deletions.
16 changes: 1 addition & 15 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,7 @@ def __init__(self, dvs):
keys = atbl.getKeys()

assert len(keys) >= 1

# Filter out DTel Acl tables
default_table_found = False
for k in keys:
if default_table_found:
break
(status, fvs) = atbl.get(k)
for item in fvs:
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1]:
self.default_acl_table = k
default_table_found = True
break
else:
break
self.default_acl_tables = keys

atbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_ENTRY")
keys = atbl.getKeys()
Expand Down
38 changes: 12 additions & 26 deletions tests/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,23 @@ class TestAcl(object):
def get_acl_table_id(self, dvs, adb):
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
keys = atbl.getKeys()
assert dvs.asicdb.default_acl_table in keys
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_table]
for k in dvs.asicdb.default_acl_tables:
assert k in keys
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_tables]

assert len(acl_tables) >= 1
assert len(acl_tables) == 1

# Filter out DTel Acl tables
for k in acl_tables:
(status, fvs) = atbl.get(k)
for item in fvs:
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1] or 'SAI_ACL_BIND_POINT_TYPE_LAG' in item[1]:
return k
else:
break

return None
return acl_tables[0]

def verify_if_any_acl_table_created(self, dvs, adb):
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
keys = atbl.getKeys()
assert dvs.asicdb.default_acl_table in keys
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_table]

# Filter out DTel Acl tables
for k in acl_tables:
(status, fvs) = atbl.get(k)
for item in fvs:
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1] or 'SAI_ACL_BIND_POINT_TYPE_LAG' in item[1]:
return True
else:
break
for k in dvs.asicdb.default_acl_tables:
assert k in keys
acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_tables]

if len(acl_tables) != 0:
return True

return False

Expand Down Expand Up @@ -158,6 +143,7 @@ def test_AclTableCreation(self, dvs):

# check acl table in asic db
test_acl_table_id = self.get_acl_table_id(dvs, adb)
assert test_acl_table_id

# check acl table group in asic db
self.verify_acl_group_num(adb, 2)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def test_CrmAcl(dvs):

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

entry_used_counter = getCrmCounterValue(dvs, key, 'crm_stats_acl_entry_used')
Expand Down
23 changes: 7 additions & 16 deletions tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,13 @@ def get_acl_table_id(self, dvs):
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
tbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
keys = tbl.getKeys()
assert dvs.asicdb.default_acl_table in keys

acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_table]
assert len(acl_tables) >= 1

# Filter out DTel Acl tables
for k in acl_tables:
(status, fvs) = tbl.get(k)
for item in fvs:
if item[0] == "SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST":
if 'SAI_ACL_BIND_POINT_TYPE_PORT' in item[1] or 'SAI_ACL_BIND_POINT_TYPE_LAG' in item[1]:
return k
else:
break

return None
for k in dvs.asicdb.default_acl_tables:
assert k in keys

acl_tables = [k for k in keys if k not in dvs.asicdb.default_acl_tables]
assert len(acl_tables) == 1

return acl_tables[0]

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

0 comments on commit 1fdcec6

Please sign in to comment.