Skip to content

Commit ae22a17

Browse files
authored
Remove QoS configurations of single indexed tables before regenerating default configuration in config qos reload --ports (#3017)
Signed-off-by: Stephen Sun <[email protected]>
1 parent 0ae5d2d commit ae22a17

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

config/main.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,12 @@ def _qos_update_ports(ctx, ports, dry_run, json_data):
29092909
click.secho("QoS definition template not found at {}".format(qos_template_file), fg="yellow")
29102910
ctx.abort()
29112911

2912-
# Remove multi indexed entries first
2912+
# Remove entries first
2913+
for table_name in tables_single_index:
2914+
for port in portset_to_handle:
2915+
if config_db.get_entry(table_name, port):
2916+
config_db.set_entry(table_name, port, None)
2917+
29132918
for table_name in tables_multi_index:
29142919
entries = config_db.get_keys(table_name)
29152920
for key in entries:

tests/buffer_test.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def test_config_int_buffer_pg_lossless_add(self, get_cmd_module):
348348
print(result.exit_code, result.output)
349349
assert result.exit_code == 0
350350
assert {'profile': 'NULL'} == db.cfgdb.get_entry('BUFFER_PG', 'Ethernet0|5')
351-
assert {'pfc_enable': '3,4,5'} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
351+
assert {'pfc_enable': '3,4,5', 'scheduler': 'port_scheduler'} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
352352

353353
# Try to add an existing entry
354354
with mock.patch('utilities_common.cli.run_command') as mock_run_command:
@@ -433,7 +433,7 @@ def test_config_int_buffer_pg_lossless_add(self, get_cmd_module):
433433
assert result.exit_code == 0
434434
keys = db.cfgdb.get_keys('BUFFER_PG')
435435
assert keys == [('Ethernet0', '0')]
436-
assert {'pfc_enable': ''} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
436+
assert {'pfc_enable': '', 'scheduler': 'port_scheduler'} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
437437

438438
def test_config_int_buffer_pg_lossless_set(self, get_cmd_module):
439439
(config, show) = get_cmd_module
@@ -456,7 +456,7 @@ def test_config_int_buffer_pg_lossless_set(self, get_cmd_module):
456456
print(result.exit_code, result.output)
457457
assert result.exit_code == 0
458458
assert {'profile': 'headroom_profile'} == db.cfgdb.get_entry('BUFFER_PG', 'Ethernet0|3-4')
459-
assert {'pfc_enable': '3,4'} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
459+
assert {'pfc_enable': '3,4', 'scheduler': 'port_scheduler'} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
460460

461461
def test_config_int_buffer_pg_lossless_remove(self, get_cmd_module):
462462
(config, show) = get_cmd_module
@@ -490,7 +490,7 @@ def test_config_int_buffer_pg_lossless_remove(self, get_cmd_module):
490490
print(result.exit_code, result.output)
491491
assert result.exit_code == 0
492492
assert [('Ethernet0', '0')] == db.cfgdb.get_keys('BUFFER_PG')
493-
assert {'pfc_enable': ''} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
493+
assert {'pfc_enable': '', 'scheduler': 'port_scheduler'} == db.cfgdb.get_entry('PORT_QOS_MAP', 'Ethernet0')
494494

495495
# Remove all lossless PGs is tested in the 'add' test case to avoid repeating adding PGs
496496

tests/mock_tables/config_db.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,8 @@
19511951
"profile": "egress_lossless_profile"
19521952
},
19531953
"PORT_QOS_MAP|Ethernet0": {
1954-
"pfc_enable": "3,4"
1954+
"pfc_enable": "3,4",
1955+
"scheduler": "port_scheduler"
19551956
},
19561957
"PORT_QOS_MAP|Ethernet4": {
19571958
"pfc_enable": "3,4"

0 commit comments

Comments
 (0)