|
14 | 14 | from ipaddress import IPv4Address, IPv6Address, ip_address, ip_network, IPv6Network |
15 | 15 | from tests.common.fixtures.duthost_utils import backup_and_restore_config_db_on_duts # noqa F401 |
16 | 16 | from tests.common.config_reload import config_reload |
| 17 | +from ipaddress import IPv4Network |
17 | 18 |
|
18 | 19 | logger = logging.getLogger(__name__) |
19 | 20 |
|
@@ -121,6 +122,38 @@ def ignore_expected_loganalyzer_exceptions(enum_rand_one_per_hwsku_frontend_host |
121 | 122 | loganalyzer[enum_rand_one_per_hwsku_frontend_hostname].ignore_regex.extend(ignoreRegex) |
122 | 123 |
|
123 | 124 |
|
| 125 | +def skip_ssip_reboot_test_when_dut_mgmt_network_is_sub_network_forced_mgmt(duthost): |
| 126 | + """ |
| 127 | + Skip test_syslog_config_work_after_reboot due to https://github.com/sonic-net/sonic-buildimage/issues/21201. |
| 128 | + When the issue is fixed, we can remove the function |
| 129 | + """ |
| 130 | + ip_intfs = duthost.show_and_parse('show ip interface') |
| 131 | + dut_mgmt_network = '' |
| 132 | + for intf in ip_intfs: |
| 133 | + if intf['interface'] == 'eth0': |
| 134 | + dut_mgmt_network = intf['ipv4 address/mask'] |
| 135 | + assert dut_mgmt_network, "Not find mgmt interface eth0" |
| 136 | + |
| 137 | + cmd_get_forced_mgmt_network_info = \ |
| 138 | + f'redis-cli -n 4 hget \"MGMT_INTERFACE|eth0|{dut_mgmt_network}\" forced_mgmt_routes@' |
| 139 | + forced_mgmt_routes_info = duthost.shell(cmd_get_forced_mgmt_network_info)["stdout"] |
| 140 | + forced_mgmt_routes_info_list = forced_mgmt_routes_info.split(",") if forced_mgmt_routes_info else [] |
| 141 | + |
| 142 | + def _is_dut_mgmt_network_subnet_forced_mgmt(dut_mgmt_network, forced_mgmt_route): |
| 143 | + """ |
| 144 | + Checks if network_a is a subnet of network_b. |
| 145 | + """ |
| 146 | + logger.info(f"dut_mgmt_network:{dut_mgmt_network}, forced_mgmt_route: {forced_mgmt_route}") |
| 147 | + net_dut_mgmt = IPv4Network(dut_mgmt_network, strict=False) |
| 148 | + net_forced_mgmt = IPv4Network(forced_mgmt_route, strict=False) |
| 149 | + return net_dut_mgmt.subnet_of(net_forced_mgmt) |
| 150 | + |
| 151 | + for forced_mgmt_route in forced_mgmt_routes_info_list: |
| 152 | + if _is_dut_mgmt_network_subnet_forced_mgmt(dut_mgmt_network, forced_mgmt_route.strip()): |
| 153 | + pytest.skip( |
| 154 | + "Skip the SSIP reboot test due to the issue:https://github.com/sonic-net/sonic-buildimage/issues/21201") |
| 155 | + |
| 156 | + |
124 | 157 | class TestSSIP: |
125 | 158 |
|
126 | 159 | @pytest.fixture(scope="class") |
@@ -540,6 +573,7 @@ def test_syslog_config_work_after_reboot(self, duthosts, enum_rand_one_per_hwsku |
540 | 573 | """ |
541 | 574 | logger.info("Starting test_syslog_config_work_after_reboot .....") |
542 | 575 | self.duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] |
| 576 | + skip_ssip_reboot_test_when_dut_mgmt_network_is_sub_network_forced_mgmt(self.duthost) |
543 | 577 | self.asichost = self.duthost.asic_instance(enum_frontend_asic_index) |
544 | 578 | syslog_config_data = SYSLOG_CONFIG_COMBINATION["vrf_set_source_set_800"] |
545 | 579 | port = syslog_config_data["port"] |
|
0 commit comments