Skip to content

Commit 3d8f622

Browse files
Fix the Unit test failure
Signed-off-by: saksarav <[email protected]>
1 parent f25f440 commit 3d8f622

File tree

1 file changed

+73
-66
lines changed

1 file changed

+73
-66
lines changed

tests/test_virtual_chassis.py

Lines changed: 73 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -915,72 +915,6 @@ def test_chassis_system_lag_id_allocator_del_id(self, vct):
915915

916916
break
917917

918-
def test_chassis_add_remove_ports(self, vct):
919-
"""Test removing and adding a port in a VOQ chassis.
920-
921-
Test validates that when a port is created the port is removed from the default vlan.
922-
"""
923-
dvss = vct.dvss
924-
for name in dvss.keys():
925-
dvs = dvss[name]
926-
buffer_model.enable_dynamic_buffer(dvs.get_config_db(), dvs.runcmd)
927-
928-
config_db = dvs.get_config_db()
929-
app_db = dvs.get_app_db()
930-
asic_db = dvs.get_asic_db()
931-
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")
932-
cfg_switch_type = metatbl.get("switch_type")
933-
cfg_hostname = metatbl.get("hostname")
934-
cfg_asic_name = metatbl.get("asic_name")
935-
936-
if cfg_switch_type == "voq":
937-
num_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT"))
938-
# Get the port info we'll flap
939-
port = config_db.get_keys('PORT')[0]
940-
port_info = config_db.get_entry("PORT", port)
941-
system_port = cfg_hostname+"|"+cfg_asic_name+"|"+port
942-
943-
# Remove port's other configs
944-
pgs = config_db.get_keys('BUFFER_PG')
945-
buf_queues = config_db.get_keys('BUFFER_QUEUE')
946-
queues = config_db.get_keys('QUEUE')
947-
948-
for key in pgs:
949-
if port in key:
950-
config_db.delete_entry('BUFFER_PG', key)
951-
app_db.wait_for_deleted_entry('BUFFER_PG_TABLE', key)
952-
953-
for key in buf_queues:
954-
if port in key:
955-
config_db.delete_entry('BUFFER_QUEUE', key)
956-
app_db.wait_for_deleted_entry('BUFFER_QUEUE_TABLE', key)
957-
958-
for key in queues:
959-
if system_port in key:
960-
config_db.delete_entry('QUEUE', key)
961-
app_db.wait_for_deleted_entry('QUEUE_TABLE', key)
962-
963-
# Remove port
964-
config_db.delete_entry('PORT', port)
965-
app_db.wait_for_deleted_entry('PORT_TABLE', port)
966-
num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
967-
num_ports)
968-
assert len(num) == num_ports
969-
970-
# Create port
971-
config_db.update_entry("PORT", port, port_info)
972-
app_db.wait_for_entry("PORT_TABLE", port)
973-
num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
974-
num_ports)
975-
assert len(num) == num_ports
976-
977-
# Check that we see the logs for removing default vlan
978-
_, logSeen = dvs.runcmd( [ "sh", "-c",
979-
"awk STARTFILE/ENDFILE /var/log/syslog | grep 'removeDefaultVlanMembers: Remove 32 VLAN members from default VLAN' | wc -l"] )
980-
assert logSeen.strip() == "1"
981-
982-
buffer_model.disable_dynamic_buffer(dvs)
983-
984918
def test_voq_egress_queue_counter(self, vct):
985919
if vct is None:
986920
return
@@ -1048,6 +982,79 @@ def test_chassis_wred_profile_on_system_ports(self, vct):
1048982
# Total number of logs = (No of system ports * No of lossless priorities) - No of lossless priorities for CPU ports
1049983
assert logSeen.strip() == str(len(system_ports)*2 - 2)
1050984

985+
def test_chassis_add_remove_ports(self, vct):
986+
"""Test removing and adding a port in a VOQ chassis.
987+
988+
Test validates that when a port is created the port is removed from the default vlan.
989+
"""
990+
dvss = vct.dvss
991+
for name in dvss.keys():
992+
dvs = dvss[name]
993+
buffer_model.enable_dynamic_buffer(dvs.get_config_db(), dvs.runcmd)
994+
995+
config_db = dvs.get_config_db()
996+
app_db = dvs.get_app_db()
997+
asic_db = dvs.get_asic_db()
998+
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")
999+
cfg_switch_type = metatbl.get("switch_type")
1000+
cfg_hostname = metatbl.get("hostname")
1001+
cfg_asic_name = metatbl.get("asic_name")
1002+
1003+
if cfg_switch_type == "voq":
1004+
num_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT"))
1005+
# Get the port info we'll flap
1006+
port = config_db.get_keys('PORT')[0]
1007+
port_info = config_db.get_entry("PORT", port)
1008+
system_port = cfg_hostname+"|"+cfg_asic_name+"|"+port
1009+
1010+
# Remove port's other configs
1011+
pgs = config_db.get_keys('BUFFER_PG')
1012+
buf_queues = config_db.get_keys('BUFFER_QUEUE')
1013+
queues = config_db.get_keys('QUEUE')
1014+
deleted_queue_key = ""
1015+
for key in pgs:
1016+
if port in key:
1017+
config_db.delete_entry('BUFFER_PG', key)
1018+
app_db.wait_for_deleted_entry('BUFFER_PG_TABLE', key)
1019+
1020+
for key in buf_queues:
1021+
if port in key:
1022+
config_db.delete_entry('BUFFER_QUEUE', key)
1023+
app_db.wait_for_deleted_entry('BUFFER_QUEUE_TABLE', key)
1024+
1025+
queue_info = {}
1026+
for key in queues:
1027+
if system_port in key:
1028+
queue_info[key] = config_db.get_entry("QUEUE", key)
1029+
config_db.delete_entry('QUEUE', key)
1030+
config_db.wait_for_deleted_entry('QUEUE_TABLE', key)
1031+
1032+
# Remove port
1033+
config_db.delete_entry('PORT', port)
1034+
app_db.wait_for_deleted_entry('PORT_TABLE', port)
1035+
num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
1036+
num_ports)
1037+
assert len(num) == num_ports
1038+
1039+
# Create port
1040+
config_db.update_entry("PORT", port, port_info)
1041+
app_db.wait_for_entry("PORT_TABLE", port)
1042+
num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT",
1043+
num_ports)
1044+
assert len(num) == num_ports
1045+
1046+
if len(queue_info):
1047+
for key, value in queue_info.items():
1048+
config_db.update_entry("QUEUE", key, value)
1049+
config_db.wait_for_entry("QUEUE", key)
1050+
1051+
# Check that we see the logs for removing default vlan
1052+
_, logSeen = dvs.runcmd( [ "sh", "-c",
1053+
"awk STARTFILE/ENDFILE /var/log/syslog | grep 'removeDefaultVlanMembers: Remove 32 VLAN members from default VLAN' | wc -l"] )
1054+
assert logSeen.strip() == "1"
1055+
1056+
buffer_model.disable_dynamic_buffer(dvs)
1057+
10511058
def test_chassis_system_intf_status(self, vct):
10521059
dvs = self.get_sup_dvs(vct)
10531060
chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock)

0 commit comments

Comments
 (0)