Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action] [PR:9054] Leave 1 ACL rule in test_crm.py::test_acl_entry #9272

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions tests/crm/test_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,23 +921,23 @@ def test_acl_entry(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_fro
ports = ",".join([tmp_ports[20], tmp_ports[25]])
recreate_acl_table(duthost, ports)
verify_acl_crm_stats(duthost, asichost, enum_rand_one_per_hwsku_frontend_hostname,
enum_frontend_asic_index, asic_collector)
enum_frontend_asic_index, asic_collector, tbinfo)
# Rebind DATA ACL at end to recover original config
recreate_acl_table(duthost, ports)
apply_acl_config(duthost, asichost, "test_acl_entry", asic_collector)
duthost.command("acl-loader delete")
else:
verify_acl_crm_stats(duthost, asichost, enum_rand_one_per_hwsku_frontend_hostname,
enum_frontend_asic_index, asic_collector)
enum_frontend_asic_index, asic_collector, tbinfo)

pytest_assert(crm_stats_checker,
"\"crm_stats_acl_entry_used\" counter was not decremented or "
"\"crm_stats_acl_entry_available\" counter was not incremented")


def verify_acl_crm_stats(duthost, asichost, enum_rand_one_per_hwsku_frontend_hostname,
enum_frontend_asic_index, asic_collector):
apply_acl_config(duthost, asichost, "test_acl_entry", asic_collector)
enum_frontend_asic_index, asic_collector, tbinfo):
apply_acl_config(duthost, asichost, "test_acl_entry", asic_collector, entry_num=2)
acl_tbl_key = asic_collector["acl_tbl_key"]
get_acl_entry_stats = "{db_cli} COUNTERS_DB HMGET {acl_tbl_key} \
crm_stats_acl_entry_used \
Expand All @@ -951,11 +951,9 @@ def verify_acl_crm_stats(duthost, asichost, enum_rand_one_per_hwsku_frontend_hos
# Get new "crm_stats_acl_entry" used and available counter value
new_crm_stats_acl_entry_used, new_crm_stats_acl_entry_available = get_crm_stats(get_acl_entry_stats, duthost)
# Verify "crm_stats_acl_entry_used" counter was incremented
pytest_assert(new_crm_stats_acl_entry_used - crm_stats_acl_entry_used == 2,
pytest_assert(new_crm_stats_acl_entry_used - crm_stats_acl_entry_used == 4,
"\"crm_stats_acl_entry_used\" counter was not incremented")

crm_stats_acl_entry_available = new_crm_stats_acl_entry_available + new_crm_stats_acl_entry_used

used_percent = get_used_percent(new_crm_stats_acl_entry_used, new_crm_stats_acl_entry_available)
if used_percent < 1:
# Preconfiguration needed for used percentage verification
Expand All @@ -969,8 +967,34 @@ def verify_acl_crm_stats(duthost, asichost, enum_rand_one_per_hwsku_frontend_hos
# Verify thresholds for "ACL entry" CRM resource
verify_thresholds(duthost, asichost, crm_cli_res="acl group entry", crm_cmd=get_acl_entry_stats)

# Remove ACL
duthost.command("acl-loader delete")
# Reduce ACL to one rule (plus default)
crm_stats_acl_entry_used = 2
apply_acl_config(duthost, asichost, "test_acl_entry", asic_collector, entry_num=1)
if duthost.facts["platform_asic"] == "broadcom-dnx":
# Each ACL rule consumes an acl entry per bind point
asicAclBindings = set()
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)

# PCs are a single bind point
portToLag = {}
for lag, lagData in mg_facts["minigraph_portchannels"].items():
for member in lagData['members']:
portToLag[member] = lag
aclBindings = mg_facts["minigraph_acls"]["DataAcl"]
for port in aclBindings:
if port in portToLag:
if asichost.portchannel_on_asic(portToLag[port]):
asicAclBindings.add(portToLag[port])
else:
if asichost.port_on_asic(port):
asicAclBindings.add(port)

freed_acl_entries = (new_crm_stats_acl_entry_used - crm_stats_acl_entry_used) * len(asicAclBindings)
else:
freed_acl_entries = new_crm_stats_acl_entry_used - crm_stats_acl_entry_used

crm_stats_acl_entry_available = new_crm_stats_acl_entry_available + freed_acl_entries

acl_tbl_key = asic_collector["acl_tbl_key"]
get_acl_entry_stats = "{db_cli} COUNTERS_DB HMGET {acl_tbl_key} \
crm_stats_acl_entry_used \
Expand Down Expand Up @@ -1003,6 +1027,9 @@ def verify_acl_crm_stats(duthost, asichost, enum_rand_one_per_hwsku_frontend_hos
crm_stats_acl_entry_available,
)

# Remove ACL
duthost.command("acl-loader delete")


def test_acl_counter(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index, collector):
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
Expand Down
Loading