|
3 | 3 | import ast
|
4 | 4 | import time
|
5 | 5 | import pytest
|
| 6 | +import buffer_model |
6 | 7 |
|
7 | 8 | class TestVirtualChassis(object):
|
8 | 9 |
|
@@ -852,7 +853,66 @@ def test_chassis_system_lag_id_allocator_del_id(self, vct):
|
852 | 853 | assert len(lagmemberkeys) == 0, "Stale system lag member entries in asic db"
|
853 | 854 |
|
854 | 855 | break
|
855 |
| - |
| 856 | + |
| 857 | + def test_chassis_add_remove_ports(self, vct): |
| 858 | + """Test removing and adding a port in a VOQ chassis. |
| 859 | +
|
| 860 | + Test validates that when a port is created the port is removed from the default vlan. |
| 861 | + """ |
| 862 | + dvss = vct.dvss |
| 863 | + for name in dvss.keys(): |
| 864 | + dvs = dvss[name] |
| 865 | + buffer_model.enable_dynamic_buffer(dvs.get_config_db(), dvs.runcmd) |
| 866 | + |
| 867 | + config_db = dvs.get_config_db() |
| 868 | + app_db = dvs.get_app_db() |
| 869 | + asic_db = dvs.get_asic_db() |
| 870 | + metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") |
| 871 | + cfg_switch_type = metatbl.get("switch_type") |
| 872 | + |
| 873 | + if cfg_switch_type == "voq": |
| 874 | + num_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT")) |
| 875 | + # Get the port info we'll flap |
| 876 | + port = config_db.get_keys('PORT')[0] |
| 877 | + port_info = config_db.get_entry("PORT", port) |
| 878 | + |
| 879 | + # Remove port's other configs |
| 880 | + pgs = config_db.get_keys('BUFFER_PG') |
| 881 | + queues = config_db.get_keys('BUFFER_QUEUE') |
| 882 | + for key in pgs: |
| 883 | + if port in key: |
| 884 | + config_db.delete_entry('BUFFER_PG', key) |
| 885 | + app_db.wait_for_deleted_entry('BUFFER_PG_TABLE', key) |
| 886 | + |
| 887 | + for key in queues: |
| 888 | + if port in key: |
| 889 | + config_db.delete_entry('BUFFER_QUEUE', key) |
| 890 | + app_db.wait_for_deleted_entry('BUFFER_QUEUE_TABLE', key) |
| 891 | + |
| 892 | + # Remove port |
| 893 | + config_db.delete_entry('PORT', port) |
| 894 | + app_db.wait_for_deleted_entry('PORT_TABLE', port) |
| 895 | + num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", |
| 896 | + num_ports-1) |
| 897 | + assert len(num) == num_ports-1 |
| 898 | + |
| 899 | + marker = dvs.add_log_marker() |
| 900 | + |
| 901 | + # Create port |
| 902 | + config_db.update_entry("PORT", port, port_info) |
| 903 | + app_db.wait_for_entry("PORT_TABLE", port) |
| 904 | + num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", |
| 905 | + num_ports) |
| 906 | + assert len(num) == num_ports |
| 907 | + |
| 908 | + # Check that we see the logs for removing default vlan |
| 909 | + matching_log = "removeDefaultVlanMembers: Remove 0 VLAN members from default VLAN" |
| 910 | + _, logSeen = dvs.runcmd( [ "sh", "-c", |
| 911 | + "awk '/{}/,ENDFILE {{print;}}' /var/log/syslog | grep '{}' | wc -l".format( marker, matching_log ) ] ) |
| 912 | + assert logSeen.strip() == "1" |
| 913 | + |
| 914 | + buffer_model.disable_dynamic_buffer(dvs.get_config_db(), dvs.runcmd) |
| 915 | + |
856 | 916 | # Add Dummy always-pass test at end as workaroud
|
857 | 917 | # for issue when Flaky fail on final test it invokes module tear-down before retrying
|
858 | 918 | def test_nonflaky_dummy():
|
|
0 commit comments