@@ -132,13 +132,17 @@ def runPtfTest(self, ptfhost, testCase='', testParams={}, relax=False, pdb=False
132132 """
133133 custom_options = " --disable-ipv6 --disable-vxlan --disable-geneve" \
134134 " --disable-erspan --disable-mpls --disable-nvgre"
135+ # Append a suffix to the logfile name if log_suffix is present in testParams
136+ log_suffix = testParams .get ("log_suffix" , "" )
137+ logfile_suffix = "_{0}" .format (log_suffix ) if log_suffix else ""
138+
135139 ptf_runner (
136140 ptfhost ,
137141 "saitests" ,
138142 testCase ,
139143 platform_dir = "ptftests" ,
140144 params = testParams ,
141- log_file = "/tmp/{0}.log" .format (testCase ) ,
145+ log_file = "/tmp/{0}{1} .log" .format (testCase , logfile_suffix ), # Include suffix in the logfile name ,
142146 qlen = 10000 ,
143147 is_python3 = True ,
144148 relax = relax ,
@@ -812,9 +816,32 @@ def __buildPortSpeeds(self, config_facts):
812816 port_speeds [attr ['speed' ]].append (etp )
813817 return port_speeds
814818
819+ @pytest .fixture (scope = 'class' , autouse = False )
820+ def configure_ip_on_ptf_intfs (self , ptfhost , get_src_dst_asic_and_duts , tbinfo ):
821+ src_dut = get_src_dst_asic_and_duts ['src_dut' ]
822+ src_mgFacts = src_dut .get_extended_minigraph_facts (tbinfo )
823+ topo = tbinfo ["topo" ]["name" ]
824+
825+ # if PTF64 and is Cisco, set ip IP address on eth interfaces of the ptf"
826+ if topo == 'ptf64' and is_cisco_device (src_dut ):
827+ minigraph_ip_interfaces = src_mgFacts ['minigraph_interfaces' ]
828+ for entry in minigraph_ip_interfaces :
829+ ptfhost .shell ("ip addr add {}/31 dev eth{}" .format (
830+ entry ['peer_addr' ], src_mgFacts ["minigraph_ptf_indices" ][entry ['attachto' ]])
831+ )
832+ yield
833+ for entry in minigraph_ip_interfaces :
834+ ptfhost .shell ("ip addr del {}/31 dev eth{}" .format (
835+ entry ['peer_addr' ], src_mgFacts ["minigraph_ptf_indices" ][entry ['attachto' ]])
836+ )
837+ return
838+ else :
839+ yield
840+ return
841+
815842 @pytest .fixture (scope = 'class' , autouse = True )
816843 def dutConfig (
817- self , request , duthosts , get_src_dst_asic_and_duts ,
844+ self , request , duthosts , configure_ip_on_ptf_intfs , get_src_dst_asic_and_duts ,
818845 lower_tor_host , tbinfo , dualtor_ports_for_duts , dut_qos_maps ): # noqa F811
819846 """
820847 Build DUT host config pertaining to QoS SAI tests
@@ -934,7 +961,7 @@ def dutConfig(
934961 testPortIds [src_dut_index ][src_asic_index ] = sorted (
935962 list (testPortIps [src_dut_index ][src_asic_index ].keys ()))
936963
937- elif topo in self .SUPPORTED_T1_TOPOS :
964+ elif topo in self .SUPPORTED_T1_TOPOS or ( topo in self . SUPPORTED_PTF_TOPOS and is_cisco_device ( src_dut )) :
938965 # T1 is supported only for 'single_asic' or 'single_dut_multi_asic'.
939966 # So use src_dut as the dut
940967 use_separated_upkink_dscp_tc_map = separated_dscp_to_tc_map_on_uplink (dut_qos_maps )
@@ -2380,6 +2407,67 @@ def populate_arp_entries(
23802407 ptfhost , testCase = saiQosTest , testParams = testParams
23812408 )
23822409
2410+ @pytest .fixture (scope = "function" , autouse = False )
2411+ def set_static_route_ptf64 (self , dutConfig , get_src_dst_asic_and_duts , dutTestParams , enum_frontend_asic_index ):
2412+ def generate_ip_address (base_ip , new_first_octet ):
2413+ octets = base_ip .split ('.' )
2414+ if len (octets ) != 4 :
2415+ raise ValueError ("Invalid IP address format" )
2416+ octets [0 ] = str (new_first_octet )
2417+ octets [2 ] = octets [3 ]
2418+ octets [3 ] = '1'
2419+ return '.' .join (octets )
2420+
2421+ def combine_ips (src_ips , dst_ips , new_first_octet ):
2422+ combined_ips_map = {}
2423+
2424+ for key , src_info in src_ips .items ():
2425+ src_ip = src_info ['peer_addr' ]
2426+ new_ip = generate_ip_address (src_ip , new_first_octet )
2427+ combined_ips_map [key ] = {'original_ip' : src_ip , 'generated_ip' : new_ip }
2428+
2429+ for key , dst_info in dst_ips .items ():
2430+ dst_ip = dst_info ['peer_addr' ]
2431+ new_ip = generate_ip_address (dst_ip , new_first_octet )
2432+ combined_ips_map [key ] = {'original_ip' : dst_ip , 'generated_ip' : new_ip }
2433+
2434+ return combined_ips_map
2435+
2436+ def configRoutePrefix (add_route ):
2437+ action = "add" if add_route else "del"
2438+ for port , entry in combined_ips_map .items ():
2439+ if enum_frontend_asic_index is None :
2440+ src_asic .shell ("config route {} prefix {}.0/24 nexthop {}" .format (
2441+ action , '.' .join (entry ['generated_ip' ].split ('.' )[:3 ]), entry ['original_ip' ]))
2442+ else :
2443+ src_asic .shell ("ip netns exec asic{} config route {} prefix {}.0/24 nexthop {}" .format (
2444+ enum_frontend_asic_index ,
2445+ action , '.' .join (entry ['generated_ip' ].split ('.' )[:3 ]),
2446+ entry ['original_ip' ])
2447+ )
2448+
2449+ if dutTestParams ["basicParams" ]["sonic_asic_type" ] != "cisco-8000" :
2450+ pytest .skip ("Traffic sanity test is not supported" )
2451+
2452+ if dutTestParams ["topo" ] != "ptf64" :
2453+ pytest .skip ("Test not supported in {} topology. Use ptf64 topo" .format (dutTestParams ["topo" ]))
2454+
2455+ src_dut_index = get_src_dst_asic_and_duts ['src_dut_index' ]
2456+ dst_dut_index = get_src_dst_asic_and_duts ['dst_dut_index' ]
2457+ src_asic_index = get_src_dst_asic_and_duts ['src_asic_index' ]
2458+ dst_asic_index = get_src_dst_asic_and_duts ['dst_asic_index' ]
2459+ src_asic = get_src_dst_asic_and_duts ['src_asic' ]
2460+
2461+ src_testPortIps = dutConfig ["testPortIps" ][src_dut_index ][src_asic_index ]
2462+ dst_testPortIps = dutConfig ["testPortIps" ][dst_dut_index ][dst_asic_index ]
2463+
2464+ new_first_octet = 100
2465+ combined_ips_map = combine_ips (src_testPortIps , dst_testPortIps , new_first_octet )
2466+
2467+ configRoutePrefix (True )
2468+ yield combined_ips_map
2469+ configRoutePrefix (False )
2470+
23832471 @pytest .fixture (scope = "function" , autouse = False )
23842472 def skip_longlink (self , dutQosConfig ):
23852473 portSpeedCableLength = dutQosConfig ["portSpeedCableLength" ]
0 commit comments