@@ -73,6 +73,7 @@ describe('Client connections', async function test() {
7373 Object . entries ( expected ) . forEach ( ( [ k , v ] ) => {
7474 assert . strictEqual ( data [ 0 ] [ k ] , v ) ;
7575 } ) ;
76+ return done ( ) ;
7677 } ) ;
7778 } ;
7879
@@ -112,27 +113,37 @@ describe('Client connections', async function test() {
112113 }
113114 assert . strictEqual ( res , 'OK' ) ;
114115
115- // Requests made with async.times will stay open when they occur
116- // during the failover window so and async.race is used to resolve
117- async . race ( [
118- ( ) => setTimeout ( ( ) => this . loadgen . emit ( 'finished' ) , 3000 ) ,
119- ( ) => async . times (
120- 100 ,
121- ( ) => makeRequest ( this , done ) ,
122- ( ) => this . loadgen . emit ( 'finished' ) ,
123- ) ,
116+ return async . race ( [
117+ cb => {
118+ setTimeout ( ( ) => {
119+ this . loadgen . emit ( 'finished' ) ;
120+ cb ( ) ;
121+ } , 3000 ) ;
122+ return undefined ;
123+ } ,
124+ cb => {
125+ async . times (
126+ 100 ,
127+ ( n , next ) => makeRequest ( this , next ) ,
128+ err => {
129+ if ( err ) { return cb ( err ) ; }
130+ this . loadgen . emit ( 'finished' ) ;
131+ return cb ( ) ;
132+ } ,
133+ ) ;
134+ return undefined ;
135+ } ,
124136 ] ) ;
125137 } ) ;
126138
127- sentinelSub . on ( 'message' , ( chan , message ) => {
128- // wait until the old master is added as a replica so any stale connections would be transfered
139+ // Add return statement here
140+ return sentinelSub . once ( 'message' , ( chan , message ) => {
129141 assert . strictEqual ( chan , '+slave' ) ;
130- // checks that ports differ between old and new master
131142 const data = message . split ( ' ' ) ;
132143 const [ oldPort , newPort ] = [ data [ 3 ] , data [ 7 ] ] ;
133144 assert . notStrictEqual ( oldPort , newPort ) ;
134145
135- return this . loadgen . on ( 'finished' , ( ) => {
146+ return this . loadgen . once ( 'finished' , ( ) => {
136147 assert ( this . requestsDuringFailover > 1 ) ;
137148 return done ( ) ;
138149 } ) ;
0 commit comments