diff --git a/tests/common/dualtor/dual_tor_mock.py b/tests/common/dualtor/dual_tor_mock.py index 0938b4b42af..c72127ffbe4 100644 --- a/tests/common/dualtor/dual_tor_mock.py +++ b/tests/common/dualtor/dual_tor_mock.py @@ -338,7 +338,7 @@ def apply_peer_switch_table_to_dut(cleanup_mocked_configs, rand_selected_dut, mo restart_swss = True cmd = 'redis-cli -n 4 HSET "{}" "{}" "{}"'.format(device_meta_key, 'subtype', 'DualToR') dut.shell(cmd=cmd) - if restart_swss: + if ((restart_swss) and (dut.get_asic_name() != 'gb')): # Restart swss on TH2 or TD3 platform to trigger syncd restart to regenerate config.bcm # We actually need to restart syncd only, but restarting syncd will also trigger swss # being restarted, and it costs more time than restarting swss diff --git a/tests/common/dualtor/dual_tor_utils.py b/tests/common/dualtor/dual_tor_utils.py index f7e259c8b96..1ea0e7a8fda 100644 --- a/tests/common/dualtor/dual_tor_utils.py +++ b/tests/common/dualtor/dual_tor_utils.py @@ -1482,8 +1482,9 @@ def is_tunnel_qos_remap_enabled(duthost): Check whether tunnel_qos_remap is enabled or not """ try: - tunnel_qos_remap_status = duthost.shell('sonic-cfggen -d -v \'SYSTEM_DEFAULTS.tunnel_qos_remap.status\'', module_ignore_errors=True)["stdout_lines"][0].decode("utf-8") - except IndexError: + tunnel_qos_remap_status = duthost.shell('sonic-cfggen -d -v \'SYSTEM_DEFAULTS.tunnel_qos_remap.status\'', + module_ignore_errors=True)["stdout_lines"][0] + except (IndexError, NameError): return False return "enabled" == tunnel_qos_remap_status diff --git a/tests/dualtor/test_ipinip.py b/tests/dualtor/test_ipinip.py index 9335d171cd0..e5afd3a1024 100644 --- a/tests/dualtor/test_ipinip.py +++ b/tests/dualtor/test_ipinip.py @@ -111,6 +111,7 @@ def stop_garp(ptfhost): if is_t0_mocked_dualtor(tbinfo): request.getfixturevalue('apply_active_state_to_orchagent') + time.sleep(30) else: request.getfixturevalue('toggle_all_simulator_ports_to_rand_selected_tor') @@ -123,7 +124,6 @@ def stop_garp(ptfhost): ptf_t1_intf = random.choice(get_t1_ptf_ports(tor, tbinfo)) logging.info("send encapsulated packet from ptf t1 interface %s", ptf_t1_intf) - time.sleep(10) with stop_garp(ptfhost): ptfadapter.dataplane.flush() testutils.send(ptfadapter, int(ptf_t1_intf.strip("eth")), encapsulated_packet) diff --git a/tests/dualtor/test_orchagent_standby_tor_downstream.py b/tests/dualtor/test_orchagent_standby_tor_downstream.py index df369f03270..c2c7eca54a3 100644 --- a/tests/dualtor/test_orchagent_standby_tor_downstream.py +++ b/tests/dualtor/test_orchagent_standby_tor_downstream.py @@ -354,6 +354,7 @@ def monitor_tunnel_and_server_traffic(torhost, expect_tunnel_traffic=True, expec logger.info("Step 1.1: Add route to a nexthop which is a standby Neighbor") set_mux_state(rand_selected_dut, tbinfo, 'standby', tor_mux_intfs, toggle_all_simulator_ports) add_nexthop_routes(rand_selected_dut, random_dst_ip, nexthops=[target_server]) + time.sleep(30) logger.info("Step 1.2: Verify traffic to this route dst is forwarded to Active ToR and equally distributed") check_tunnel_balance(**test_params) monitor_tunnel_and_server_traffic(rand_selected_dut, expect_server_traffic=False, expect_tunnel_traffic=True) @@ -361,12 +362,14 @@ def monitor_tunnel_and_server_traffic(torhost, expect_tunnel_traffic=True, expec logger.info("Stage 2: Verify Active Forwarding") logger.info("Step 2.1: Simulate Mux state change to active") set_mux_state(rand_selected_dut, tbinfo, 'active', tor_mux_intfs, toggle_all_simulator_ports) + time.sleep(30) logger.info("Step 2.2: Verify traffic to this route dst is forwarded directly to server") monitor_tunnel_and_server_traffic(rand_selected_dut, expect_server_traffic=True, expect_tunnel_traffic=False) logger.info("Stage 3: Verify Standby Forwarding Again") logger.info("Step 3.1: Simulate Mux state change to standby") set_mux_state(rand_selected_dut, tbinfo, 'standby', tor_mux_intfs, toggle_all_simulator_ports) + time.sleep(30) logger.info("Step 3.2: Verify traffic to this route dst is now redirected back to Active ToR and equally distributed") monitor_tunnel_and_server_traffic(rand_selected_dut, expect_server_traffic=False, expect_tunnel_traffic=True) check_tunnel_balance(**test_params) diff --git a/tests/dualtor/test_tor_ecn.py b/tests/dualtor/test_tor_ecn.py index 6073e47c351..9b078ca12c1 100644 --- a/tests/dualtor/test_tor_ecn.py +++ b/tests/dualtor/test_tor_ecn.py @@ -19,18 +19,20 @@ from ptf import mask from ptf import testutils from scapy.all import Ether, IP -from tests.common.dualtor.dual_tor_mock import * +from tests.common.dualtor.dual_tor_mock import * # noqa F403 from tests.common.dualtor.dual_tor_utils import get_t1_ptf_ports -from tests.common.dualtor.dual_tor_utils import rand_selected_interface -from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor -from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor +from tests.common.dualtor.dual_tor_utils import rand_selected_interface # noqa F401 +from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor # noqa F401 +from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor # noqa F401 from tests.common.utilities import is_ipv4_address -from tests.common.fixtures.ptfhost_utils import run_icmp_responder -from tests.common.fixtures.ptfhost_utils import run_garp_service -from tests.common.fixtures.ptfhost_utils import change_mac_addresses +from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401 +from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa F401 +from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401 from tests.common.utilities import dump_scapy_packet_show_output from tests.common.dualtor.tunnel_traffic_utils import derive_queue_id_from_dscp, derive_out_dscp_from_inner_dscp from tests.common.dualtor.dual_tor_utils import is_tunnel_qos_remap_enabled +from tests.common.dualtor.dual_tor_utils import config_active_active_dualtor_active_standby +from tests.common.dualtor.dual_tor_utils import validate_active_active_dualtor_setup pytestmark = [ pytest.mark.topology("dualtor") @@ -99,8 +101,7 @@ def build_encapsulated_ip_packet( inner_ttl = random.choice(list(range(3, 65))) inner_ecn = random.choice(list(range(0, 3))) - if is_tunnel_qos_remap_enabled(tor): - outer_dscp = derive_out_dscp_from_inner_dscp(tor, inner_dscp) + outer_dscp = derive_out_dscp_from_inner_dscp(tor, inner_dscp) outer_ecn = inner_ecn logging.info("Inner DSCP: {0:06b}, Inner ECN: {1:02b}".format(inner_dscp, inner_ecn)) @@ -309,17 +310,31 @@ def runcmd(): except: pytest.skip('file {} not found'.format(file)) -@pytest.mark.parametrize("dscp", [3, 4, 2, 6]) #lossless queue is 3 or 4 or 2 or 6. + +@pytest.fixture +def setup_active_active_ports(active_active_ports, rand_selected_dut, rand_unselected_dut, # noqa F811 + config_active_active_dualtor_active_standby, # noqa F811 + validate_active_active_dualtor_setup): # noqa F811 + if active_active_ports: + logging.info("Configuring {} as active".format(rand_unselected_dut.hostname)) + logging.info("Configuring {} as standby".format(rand_selected_dut.hostname)) + config_active_active_dualtor_active_standby(rand_unselected_dut, rand_selected_dut, active_active_ports) + + return + + +@pytest.mark.parametrize("dscp", [3, 4, 2, 6]) # lossless queue is 3 or 4 or 2 or 6. def test_dscp_to_queue_during_encap_on_standby( dscp, setup_dualtor_tor_standby, - rand_selected_interface, ptfadapter, + rand_selected_interface, ptfadapter, # noqa F811 tbinfo, - rand_selected_dut, - tunnel_traffic_monitor, + rand_selected_dut, # noqa F811 + tunnel_traffic_monitor, # noqa F811 duthosts, rand_one_dut_hostname, - write_standby + write_standby, + setup_active_active_ports ): """ Test if DSCP to Q mapping for outer header is matching with inner header during encap on standby @@ -376,9 +391,10 @@ def test_ecn_during_decap_on_active( def test_ecn_during_encap_on_standby( dscp, setup_dualtor_tor_standby, - rand_selected_interface, ptfadapter, - tbinfo, rand_selected_dut, tunnel_traffic_monitor, - write_standby + rand_selected_interface, ptfadapter, # noqa F811 + tbinfo, rand_selected_dut, tunnel_traffic_monitor, # noqa F811 + write_standby, + setup_active_active_ports ): """ Test if the ECN stamping on outer header is matching with inner during encap on standby