diff --git a/ansible/roles/test/files/ptftests/advanced-reboot.py b/ansible/roles/test/files/ptftests/advanced-reboot.py index 3e5cd398a64..2f2b83ac82c 100644 --- a/ansible/roles/test/files/ptftests/advanced-reboot.py +++ b/ansible/roles/test/files/ptftests/advanced-reboot.py @@ -769,7 +769,7 @@ def generate_ping_dut_lo(self): ip_src=self.from_server_src_addr, ip_dst=dut_lo_ipv4) - self.ping_dut_exp_packet = Mask(exp_packet) + self.ping_dut_exp_packet = Mask(exp_packet) self.ping_dut_exp_packet.set_do_not_care_scapy(scapy.Ether, "dst") self.ping_dut_exp_packet.set_do_not_care_scapy(scapy.IP, "dst") self.ping_dut_exp_packet.set_do_not_care_scapy(scapy.IP, "id") @@ -1559,12 +1559,15 @@ def no_flood(self, packet): """ This method filters packets which are unique (i.e. no floods). """ - if (not int(str(packet[scapyall.TCP].payload)) in self.unique_id) and (packet[scapyall.Ether].src == self.dut_mac): + if (not int(str(packet[scapyall.TCP].payload)) in self.unique_id) and \ + (packet[scapyall.Ether].src == self.dut_mac or packet[scapyall.Ether].src == self.vlan_mac): # This is a unique (no flooded) received packet. + # for dualtor, t1->server rcvd pkt will have src MAC as vlan_mac, and server->t1 rcvd pkt will have src MAC as dut_mac self.unique_id.append(int(str(packet[scapyall.TCP].payload))) return True - elif packet[scapyall.Ether].dst == self.dut_mac: + elif packet[scapyall.Ether].dst == self.dut_mac or packet[scapyall.Ether].dst == self.vlan_mac: # This is a sent packet. + # for dualtor, t1->server sent pkt will have dst MAC as dut_mac, and server->t1 sent pkt will have dst MAC as vlan_mac return True else: return False @@ -1630,14 +1633,18 @@ def examine_flow(self, filename = None): missed_t1_to_vlan = 0 self.disruption_start, self.disruption_stop = None, None for packet in packets: - if packet[scapyall.Ether].dst == self.dut_mac: + if packet[scapyall.Ether].dst == self.dut_mac or packet[scapyall.Ether].dst == self.vlan_mac: # This is a sent packet - keep track of it as payload_id:timestamp. + # for dualtor both MACs are needed: + # t1->server sent pkt will have dst MAC as dut_mac, and server->t1 sent pkt will have dst MAC as vlan_mac sent_payload = int(str(packet[scapyall.TCP].payload)) sent_packets[sent_payload] = packet.time sent_counter += 1 continue - if packet[scapyall.Ether].src == self.dut_mac: + if packet[scapyall.Ether].src == self.dut_mac or packet[scapyall.Ether].src == self.vlan_mac: # This is a received packet. + # for dualtor both MACs are needed: + # t1->server rcvd pkt will have src MAC as vlan_mac, and server->t1 rcvd pkt will have src MAC as dut_mac received_time = packet.time received_payload = int(str(packet[scapyall.TCP].payload)) if (received_payload % 5) == 0 : # From vlan to T1. @@ -1652,6 +1659,8 @@ def examine_flow(self, filename = None): continue if received_payload - prev_payload > 1: # Packets in a row are missing, a disruption. + self.log("received_payload: {}, prev_payload: {}, sent_counter: {}, received_counter: {}".format( + received_payload, prev_payload, sent_counter, received_counter)) lost_id = (received_payload -1) - prev_payload # How many packets lost in a row. disrupt = (sent_packets[received_payload] - sent_packets[prev_payload + 1]) # How long disrupt lasted. # Add disrupt to the dict: @@ -1762,7 +1771,7 @@ def wait_dut_to_warm_up(self): up_time = None if elapsed > warm_up_timeout_secs: - raise Exception("Control plane didn't come up within warm up timeout") + raise Exception("IO didn't come up within warm up timeout. Control plane: {}, Data plane: {}".format(ctrlplane, dataplane)) time.sleep(1) # check until flooding is over. Flooding happens when FDB entry of @@ -1974,6 +1983,11 @@ def pingDut(self): total_rcv_pkt_cnt = testutils.count_matched_packets_all_ports(self, self.ping_dut_exp_packet, self.vlan_ports, timeout=self.PKT_TOUT) + if self.vlan_mac != self.dut_mac: + # handle two-for-one icmp reply for dual tor (when vlan and dut mac are diff): + # icmp_responder will also generate a response for this ICMP req, ignore that reply + total_rcv_pkt_cnt = total_rcv_pkt_cnt - self.ping_dut_pkts + self.log("Send %5d Received %5d ping DUT" % (self.ping_dut_pkts, total_rcv_pkt_cnt), True) return total_rcv_pkt_cnt diff --git a/tests/common/fixtures/advanced_reboot.py b/tests/common/fixtures/advanced_reboot.py index 5c4f55f3136..3b6afddf561 100644 --- a/tests/common/fixtures/advanced_reboot.py +++ b/tests/common/fixtures/advanced_reboot.py @@ -35,7 +35,7 @@ class AdvancedReboot: Test cases can trigger test start utilizing runRebootTestcase API. """ - def __init__(self, request, duthost, ptfhost, localhost, tbinfo, creds, **kwargs): + def __init__(self, request, duthosts, duthost, ptfhost, localhost, tbinfo, creds, **kwargs): """ Class constructor. @param request: pytest request object @@ -76,6 +76,7 @@ def __init__(self, request, duthost, ptfhost, localhost, tbinfo, creds, **kwargs self.kvmTest = False self.request = request + self.duthosts = duthosts self.duthost = duthost self.ptfhost = ptfhost self.localhost = localhost @@ -598,6 +599,10 @@ def runRebootTestcase(self, prebootList=None, inbootList=None, prebootFiles='pee return self.runRebootTest() def __setupRebootOper(self, rebootOper): + if "dualtor" in self.getTestbedType(): + for device in self.duthosts: + device.shell("config mux mode manual all") + down_ports = 0 if "dut_lag_member_down" in str(rebootOper) \ or "neigh_lag_member_down" in str(rebootOper) \ @@ -640,6 +645,10 @@ def __verifyRebootOper(self, rebootOper): rebootOper.verify() def __revertRebootOper(self, rebootOper): + if "dualtor" in self.getTestbedType(): + for device in self.duthosts: + device.shell("config mux mode auto all") + if isinstance(rebootOper, SadOperation): logger.info('Running revert handler for reboot operation {}'.format(rebootOper)) rebootOper.revert() @@ -820,7 +829,7 @@ def get_advanced_reboot(**kwargs): API that returns instances of AdvancedReboot class """ assert len(instances) == 0, "Only one instance of reboot data is allowed" - advancedReboot = AdvancedReboot(request, duthost, ptfhost, localhost, tbinfo, creds, **kwargs) + advancedReboot = AdvancedReboot(request, duthosts, duthost, ptfhost, localhost, tbinfo, creds, **kwargs) instances.append(advancedReboot) return advancedReboot diff --git a/tests/platform_tests/test_advanced_reboot.py b/tests/platform_tests/test_advanced_reboot.py index f062de14dc6..9bfa37cf8ae 100644 --- a/tests/platform_tests/test_advanced_reboot.py +++ b/tests/platform_tests/test_advanced_reboot.py @@ -8,6 +8,9 @@ from tests.platform_tests.verify_dut_health import add_fail_step_to_reboot # lgtm[py/unused-import] from tests.platform_tests.warmboot_sad_cases import get_sad_case_list, SAD_CASE_LIST +from tests.common.fixtures.ptfhost_utils import run_icmp_responder +from tests.common.fixtures.ptfhost_utils import run_garp_service + pytestmark = [ pytest.mark.disable_loganalyzer, pytest.mark.topology('t0'),