Skip to content

Commit

Permalink
Update get_acl_couner with command instead of getting value from redis (
Browse files Browse the repository at this point in the history
#5616)

What is the motivation for this PR?
We can't get acl counters from redis COUNTERS_DB due to this RP sonic-net/sonic-swss#1943.
test_acl_outer_vlan.py keeps failing because of the error Failed: Failed to retrieve acl counter for DATAACL_ingress_ipv6|rule_1.

How did you do it?
Parse the output of aclshow to get counters.

How did you verify/test it?
run acl/test_acl_outer_vlan.py

Signed-off-by: Zhaohui Sun <[email protected]>
  • Loading branch information
ZhaohuiS authored May 9, 2022
1 parent 1257362 commit 06e0926
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/acl/test_acl_outer_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,16 @@ def get_acl_counter(duthost, table_name, rule_name, timeout=ACL_COUNTERS_UPDATE_
Returns:
Acl counter value for packets
"""
cmd = "redis-cli -n 2 hget 'COUNTERS:{}:{}' Packets"
# Wait for orchagent to update the ACL counters
time.sleep(timeout)
result = duthost.shell(cmd.format(table_name, rule_name))['stdout']
if result == "":
result = duthost.show_and_parse('aclshow -a')

if len(result) == 0:
pytest.fail("Failed to retrieve acl counter for {}|{}".format(table_name, rule_name))
return int(result)
for rule in result:
if table_name == rule['table name'] and rule_name == rule['rule name']:
return int(rule['packets count'])
pytest.fail("Failed to retrieve acl counter for {}|{}".format(table_name, rule_name))


def craft_packet(src_mac, dst_mac, dst_ip, ip_version, stage, tagged_mode, vlan_id=10, outer_vlan_id=0, pkt_type=None):
Expand Down

0 comments on commit 06e0926

Please sign in to comment.