Skip to content

Commit

Permalink
[dvs/copp] Adjust policer checks in VS tests for default COPP policers (
Browse files Browse the repository at this point in the history
sonic-net#1519)

Signed-off-by: Danny Allen <daall@microsoft.com>
  • Loading branch information
daall authored Nov 25, 2020
1 parent c975c8d commit c88d77f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def _populate_default_asic_db_values(self) -> None:
self.default_acl_tables = self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE")
self.default_acl_entries = self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ACL_ENTRY")

self.default_copp_policers = self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_POLICER")


class ApplDbValidator(DVSDatabase):
NEIGH_TABLE = "NEIGH_TABLE"
Expand Down Expand Up @@ -1102,6 +1104,7 @@ def get_asic_db(self) -> AsicDbValidator:
db = DVSDatabase(self.ASIC_DB_ID, self.redis_sock)
db.default_acl_tables = self.asicdb.default_acl_tables
db.default_acl_entries = self.asicdb.default_acl_entries
db.default_copp_policers = self.asicdb.default_copp_policers
db.port_name_map = self.asicdb.portnamemap
db.default_vlan_id = self.asicdb.default_vlan_id
db.port_to_id_map = self.asicdb.portoidmap
Expand Down
6 changes: 4 additions & 2 deletions tests/dvslib/dvs_policer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ def remove_policer(self, name):
self.config_db.delete_entry("POLICER", name)

def verify_policer(self, name, expected=1):
self.asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_POLICER", expected)
self.asic_db.wait_for_n_keys(
"ASIC_STATE:SAI_OBJECT_TYPE_POLICER",
expected + len(self.asic_db.default_copp_policers)
)

def verify_no_policer(self):
self.asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ACL_ENTRY", 0)

2 changes: 1 addition & 1 deletion tests/test_mirror_policer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_MirrorPolicer(self, dvs, testlog):

# check asic database
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_POLICER")
policer_entries = tbl.getKeys()
policer_entries = [p for p in tbl.getKeys() if p not in dvs.asicdb.default_copp_policers]
assert len(policer_entries) == 1
policer_oid = policer_entries[0]

Expand Down
4 changes: 2 additions & 2 deletions tests/test_policer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_PolicerBasic(self, dvs, testlog):

# check asic database
tbl = swsscommon.Table(dvs.adb, "ASIC_STATE:SAI_OBJECT_TYPE_POLICER")
policer_entries = tbl.getKeys()
policer_entries = [p for p in tbl.getKeys() if p not in dvs.asicdb.default_copp_policers]
assert len(policer_entries) == 1

(status, fvs) = tbl.get(policer_entries[0])
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_PolicerBasic(self, dvs, testlog):

# check asic database
tbl = swsscommon.Table(dvs.adb, "ASIC_STATE:SAI_OBJECT_TYPE_POLICER")
policer_entries = tbl.getKeys()
policer_entries = [p for p in tbl.getKeys() if p not in dvs.asicdb.default_copp_policers]
assert len(policer_entries) == 0


Expand Down

0 comments on commit c88d77f

Please sign in to comment.