Skip to content

Commit 62d0c77

Browse files
Fix remove_dataacl_table fixture to correctly delete and restore DATAACL table (#21021)
What is the motivation for this PR? As DATAACL was never restored for dualtor topologies, sometimes DATAACL table was bound to the same PortChannels that carry the BGP traffic, that lead to routes corruption and various tests failing. How did you do it? Modified the fixture to correctly check and delete and later accordingly restore the table How did you verify/test it? Ran test/test_acl_stress and verified the DATAACL was being restored in teardown
1 parent 2727d09 commit 62d0c77

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

tests/acl/test_stress_acl.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ def setup_table_and_rules(rand_selected_dut, prepare_test_port):
116116

117117

118118
@pytest.fixture(scope="module", autouse=True)
119-
def remove_dataacl_table(duthosts, rand_selected_dut):
119+
def remove_dataacl_table(duthosts):
120120
"""
121121
Remove DATAACL to free TCAM resources.
122122
The change is written to configdb as we don't want DATAACL recovered after reboot
123123
"""
124124
TABLE_NAME_1 = "DATAACL"
125+
data_acl_existing_duts = []
125126
for duthost in duthosts:
126127
lines = duthost.shell(cmd="show acl table {}".format(TABLE_NAME_1))['stdout_lines']
127128
data_acl_existing = False
@@ -133,23 +134,25 @@ def remove_dataacl_table(duthosts, rand_selected_dut):
133134
if data_acl_existing:
134135
# Remove DATAACL
135136
logger.info("Removing ACL table {}".format(TABLE_NAME_1))
136-
rand_selected_dut.shell(cmd="config acl remove table {}".format(TABLE_NAME_1))
137+
duthost.shell(cmd="config acl remove table {}".format(TABLE_NAME_1))
138+
data_acl_existing_duts.append(duthost)
137139

138-
if not data_acl_existing:
140+
if not data_acl_existing_duts:
139141
yield
140142
return
141143

142144
yield
143145
# Recover DATAACL
144146
config_db_json = "/etc/sonic/config_db.json"
145-
output = rand_selected_dut.shell("sonic-cfggen -j {} --var-json \"ACL_TABLE\"".format(config_db_json))['stdout']
146-
entry_json = json.loads(output)
147-
if TABLE_NAME_1 in entry_json:
148-
entry = entry_json[TABLE_NAME_1]
149-
cmd_create_table = "config acl add table {} {} -p {} -s {}"\
150-
.format(TABLE_NAME_1, entry['type'], ",".join(entry['ports']), entry['stage'])
151-
logger.info("Restoring ACL table {}".format(TABLE_NAME_1))
152-
rand_selected_dut.shell(cmd_create_table)
147+
for duthost in data_acl_existing_duts:
148+
output = duthost.shell("sonic-cfggen -j {} --var-json \"ACL_TABLE\"".format(config_db_json))['stdout']
149+
entry_json = json.loads(output)
150+
if TABLE_NAME_1 in entry_json:
151+
entry = entry_json[TABLE_NAME_1]
152+
cmd_create_table = "config acl add table {} {} -p {} -s {}"\
153+
.format(TABLE_NAME_1, entry['type'], ",".join(entry['ports']), entry['stage'])
154+
logger.info("Restoring ACL table {}".format(TABLE_NAME_1))
155+
duthost.shell(cmd_create_table)
153156

154157

155158
@pytest.fixture(scope='module')

0 commit comments

Comments
 (0)