@@ -569,28 +569,25 @@ describe("The node_redis client", function () {
569569 } ) ;
570570
571571 describe ( 'retry_max_delay' , function ( ) {
572- var args = config . configureClient ( parser , ip , {
573- retry_max_delay : 1 // ms
574- } ) ;
575-
576572 it ( "sets upper bound on how long client waits before reconnecting" , function ( done ) {
577- var time = new Date ( ) . getTime ( ) ;
578- var reconnecting = false ;
573+ var time ;
574+ var timeout = process . platform !== 'win32' ? 20 : 100 ;
579575
580- client = redis . createClient . apply ( redis . createClient , args ) ;
576+ client = redis . createClient . apply ( null , config . configureClient ( parser , ip , {
577+ retry_max_delay : 1 // ms
578+ } ) ) ;
581579 client . on ( 'ready' , function ( ) {
582- if ( ! reconnecting ) {
583- reconnecting = true ;
584- client . retry_delay = 1000 ;
585- client . retry_backoff = 1 ;
586- client . stream . end ( ) ;
580+ if ( this . times_connected === 1 ) {
581+ this . stream . end ( ) ;
582+ time = Date . now ( ) ;
587583 } else {
588- client . end ( true ) ;
589- var lasted = new Date ( ) . getTime ( ) - time ;
590- assert . ok ( lasted < 100 ) ;
591- return done ( ) ;
584+ done ( ) ;
592585 }
593586 } ) ;
587+ client . on ( 'reconnecting' , function ( ) {
588+ time = Date . now ( ) - time ;
589+ assert ( time < timeout , 'The reconnect should not have taken longer than ' + timeout + ' but it took ' + time ) ;
590+ } ) ;
594591 client . on ( 'error' , function ( err ) {
595592 // This is rare but it might be triggered.
596593 // So let's have a robust test
0 commit comments