3434from ptf .testutils import simple_tcp_packet
3535from tests .common .fixtures .conn_graph_facts import conn_graph_facts , fanout_graph_facts # noqa F401
3636from tests .common .helpers .pfc_storm import PFCStorm
37+ from tests .common .helpers .pfcwd_helper import send_background_traffic
3738
3839
3940pytestmark = [
@@ -354,32 +355,34 @@ def test_separated_qos_map_on_tor(ptfhost, rand_selected_dut, rand_unselected_du
354355 counter_poll_config (rand_selected_dut , 'queue' , 10000 )
355356
356357
357- def pfc_pause_test (storm_handler , peer_info , prio , ptfadapter , dut , port , queue , pkt , src_port , exp_pkt , dst_ports ):
358+ def pfc_pause_test (ptfhost , storm_handler , peer_info , prio , ptfadapter , dut , port , queue , pkt , src_port , exp_pkt ,
359+ dst_ports , test_ports_info ):
358360 try :
359- # Start PFC storm from leaf fanout switch
360- start_pfc_storm (storm_handler , peer_info , prio )
361- ptfadapter .dataplane .flush ()
362- # Record the queue counter before sending test packet
363- base_queue_count = get_queue_counter (dut , port , queue , False ) # noqa F841
364- # Send testing packet again
365- testutils .send_packet (ptfadapter , src_port , pkt , 1 )
366- # The packet should be paused
367- testutils .verify_no_packet_any (ptfadapter , exp_pkt , dst_ports )
368- # Check the queue counter didn't increase
369- queue_count = get_queue_counter (dut , port , queue , False ) # noqa F841
370- # after 10 sec delay in queue counter reading, pfc frames sending might actually had already stopped.
371- # so bounce back packet might still send out, and queue counter increased accordingly.
372- # and then caused flaky test faiure.
373- # temporarily disable the assert queue counter here until find a better solution,
374- # such as reading counter using sai thrift API
375- # assert base_queue_count == queue_count
376- return True
361+ with send_background_traffic (dut , ptfhost , queue , [port ], test_ports_info ):
362+ # Start PFC storm from leaf fanout switch
363+ start_pfc_storm (storm_handler , peer_info , prio )
364+ ptfadapter .dataplane .flush ()
365+ # Record the queue counter before sending test packet
366+ base_queue_count = get_queue_counter (dut , port , queue , False ) # noqa F841
367+ # Send testing packet again
368+ testutils .send_packet (ptfadapter , src_port , pkt , 1 )
369+ # The packet should be paused
370+ testutils .verify_no_packet_any (ptfadapter , exp_pkt , dst_ports )
371+ # Check the queue counter didn't increase
372+ queue_count = get_queue_counter (dut , port , queue , False ) # noqa F841
373+ # after 10 sec delay in queue counter reading, pfc frames sending might actually had already stopped.
374+ # so bounce back packet might still send out, and queue counter increased accordingly.
375+ # and then caused flaky test faiure.
376+ # temporarily disable the assert queue counter here until find a better solution,
377+ # such as reading counter using sai thrift API
378+ # assert base_queue_count == queue_count
379+ return True
377380 finally :
378381 stop_pfc_storm (storm_handler )
379382
380383
381384def test_pfc_pause_extra_lossless_standby (ptfhost , fanouthosts , rand_selected_dut , rand_unselected_dut ,
382- setup_standby_ports_on_rand_selected_tor ,
385+ setup_standby_ports_on_rand_selected_tor , setup_pfc_test , # noqa F811
383386 toggle_all_simulator_ports_to_rand_unselected_tor , tbinfo , ptfadapter , conn_graph_facts , fanout_graph_facts , dut_config ): # noqa F811
384387 """
385388 The test case is to verify PFC pause frame can pause extra lossless queues in dualtor deployment.
@@ -389,6 +392,7 @@ def test_pfc_pause_extra_lossless_standby(ptfhost, fanouthosts, rand_selected_du
389392 3. Generate PFC pause on fanout switch (T1 ports)
390393 4. Verify lossless traffic are paused
391394 """
395+ setup_info = setup_pfc_test
392396 if "cisco-8000" in dut_config ["asic_type" ]:
393397 pytest .skip ("Replacing test with test_pfc_watermark_extra_lossless_standby for Cisco-8000." )
394398 TEST_DATA = {
@@ -440,8 +444,8 @@ def test_pfc_pause_extra_lossless_standby(ptfhost, fanouthosts, rand_selected_du
440444 retry = 0
441445 while retry < PFC_PAUSE_TEST_RETRY_MAX :
442446 try :
443- if pfc_pause_test (storm_handler , peer_info , prio , ptfadapter , rand_selected_dut , actual_port_name ,
444- queue , pkt , src_port , exp_pkt , dst_ports ):
447+ if pfc_pause_test (ptfhost , storm_handler , peer_info , prio , ptfadapter , rand_selected_dut ,
448+ actual_port_name , queue , pkt , src_port , exp_pkt , dst_ports , setup_info [ 'test_ports' ] ):
445449 break
446450 except AssertionError as err :
447451 retry += 1
@@ -457,7 +461,7 @@ def test_pfc_pause_extra_lossless_standby(ptfhost, fanouthosts, rand_selected_du
457461
458462
459463def test_pfc_pause_extra_lossless_active (ptfhost , fanouthosts , rand_selected_dut , rand_unselected_dut ,
460- setup_standby_ports_on_rand_unselected_tor ,
464+ setup_standby_ports_on_rand_unselected_tor , setup_pfc_test , # noqa F811
461465 toggle_all_simulator_ports_to_rand_selected_tor , tbinfo , ptfadapter , conn_graph_facts , fanout_graph_facts , dut_config ): # noqa F811
462466 """
463467 The test case is to verify PFC pause frame can pause extra lossless queues in dualtor deployment.
@@ -467,6 +471,7 @@ def test_pfc_pause_extra_lossless_active(ptfhost, fanouthosts, rand_selected_dut
467471 3. Generate PFC pause on fanout switch (Server facing ports)
468472 4. Verify lossless traffic are paused
469473 """
474+ setup_info = setup_pfc_test
470475 if "cisco-8000" in dut_config ["asic_type" ]:
471476 pytest .skip ("Replacing test with test_pfc_watermark_extra_lossless_active for Cisco-8000." )
472477 TEST_DATA = {
@@ -516,9 +521,9 @@ def test_pfc_pause_extra_lossless_active(ptfhost, fanouthosts, rand_selected_dut
516521 retry = 0
517522 while retry < PFC_PAUSE_TEST_RETRY_MAX :
518523 try :
519- if pfc_pause_test (storm_handler , peer_info , prio , ptfadapter , rand_selected_dut ,
524+ if pfc_pause_test (ptfhost , storm_handler , peer_info , prio , ptfadapter , rand_selected_dut ,
520525 dualtor_meta ['selected_port' ], queue , tunnel_pkt .exp_pkt , src_port , exp_pkt ,
521- dst_ports ):
526+ dst_ports , setup_info [ 'test_ports' ] ):
522527 break
523528 except AssertionError as err :
524529 retry += 1
0 commit comments