@@ -627,15 +627,16 @@ def ClientServerExpectedFailureTest( server_extra_args=[], client_extra_args=[],
627627 'local' , 1 , None , None ),
628628]
629629
630- def ClientServerTest ( server_extra_args = [], client_extra_args = [], expected_route = None , ice_impl = 1 , expected_counters = None , expected_candidates = None ):
630+ def ClientServerTest ( server_extra_args = [], client_extra_args = [], expected_route = None , ice_impl = 1 , expected_counters = None , expected_candidates = None , timeout_sec = None ):
631631 global g_failed
632632 impl_args = [ '--ice-implementation' , str (ice_impl ) ]
633633 server = StartClientInThread ( "server" , "peer_server" , "peer_client" , server_extra_args + impl_args )
634634 client = StartClientInThread ( "client" , "peer_client" , "peer_server" , client_extra_args + impl_args )
635635
636636 # Wait for clients to shutdown. Nuke them if necessary
637- server .join ( timeout = 20 * g_repeat )
638- client .join ( timeout = 20 * g_repeat )
637+ t = timeout_sec if timeout_sec is not None else 20 * g_repeat
638+ server .join ( timeout = t )
639+ client .join ( timeout = t )
639640
640641 # Verify route types if an expected value was provided
641642 if expected_route is not None :
@@ -712,7 +713,7 @@ def _check_subset( received, gathered, receiver, gatherer ):
712713
713714stun = StartProcessInThread ( "stun" , [ sys .executable , stun_server_script ,
714715 '--host' , g_stun_ip , '--host6' , g_stun_ipv6 , '--port' , str (g_stun_port ),
715- '--relay-latency' , '75' ],
716+ '--relay-latency' , '75' , '--allocation-lifetime' , '15' ],
716717 ready_message = "STUN/TURN server listening on" , ready_event = g_stun_ready )
717718
718719if not g_stun_ready .wait ( timeout = g_server_startup_timeout ):
@@ -754,6 +755,20 @@ def _check_subset( received, gathered, receiver, gatherer ):
754755 if g_failed :
755756 break
756757
758+ # TURN allocation refresh test: run long enough (~20s, 400 ticks) to see two refreshes.
759+ # With --allocation-lifetime 15, refreshes fire at ~7.5s and ~15s from allocation.
760+ # refresh_send >= 2 confirms both fires; allocate_send == 1 confirms no re-allocation.
761+ if not g_failed :
762+ print ( "=================================================================" )
763+ print ( "Test: TURN allocation refresh (symmetric NAT, 400 ticks)" )
764+ print ( "=================================================================" )
765+ _refresh_args = [ '--ticks' , '400' ] + _nat ( _SRV_INT , _SRV_GW , 'symmetric' )
766+ _refresh_cli_args = [ '--ticks' , '400' ] + _nat ( _CLI_INT , _CLI_GW , 'symmetric' )
767+ ClientServerTest ( _refresh_args , _refresh_cli_args ,
768+ expected_route = 'relay' , ice_impl = 1 ,
769+ expected_counters = { 'refresh_send' : (2 , None ), 'allocate_send' : (1 , 1 ) },
770+ timeout_sec = 35 * g_repeat )
771+
757772# Run the expected-failure tests
758773if not g_failed :
759774 for desc , srv_args , cli_args , kwargs in FAILURE_TEST_CASES :
0 commit comments