@@ -74,7 +74,18 @@ class Worker extends BaseRunner_1.BaseRunner {
7474 return false ;
7575 }
7676 console . log ( `[ci-queue] Failed test groups: ${ failedTestGroups } ` ) ;
77- await this . push ( failedTestGroups ) ;
77+ const failedTestGroupTimeouts = [ ] ;
78+ for ( const failedTestGroup of failedTestGroups ) {
79+ const testSpec = tests . find ( ( test ) => test . name === failedTestGroup ) ;
80+ if ( testSpec ) {
81+ failedTestGroupTimeouts . push ( testSpec ) ;
82+ }
83+ else {
84+ console . log ( "Failed to find timeout for test group" , failedTestGroup , ". defaulting to" , this . config . timeout ) ;
85+ failedTestGroupTimeouts . push ( { name : failedTestGroup , timeout : this . config . timeout } ) ;
86+ }
87+ }
88+ await this . push ( failedTestGroupTimeouts ) ;
7889 return true ;
7990 }
8091 console . log ( `[ci-queue] Populating tests` ) ;
@@ -105,24 +116,31 @@ class Worker extends BaseRunner_1.BaseRunner {
105116 return reservedTest ;
106117 }
107118 async tryToReserveTest ( ) {
108- return await this . client . reserve ( this . key ( 'queue' ) , this . key ( 'running' ) , this . key ( 'processed' ) , this . key ( 'worker' , this . config . workerId , 'queue' ) , this . key ( 'owners' ) , Date . now ( ) / 1000 ) ;
119+ return await this . client . reserve ( this . key ( 'queue' ) , this . key ( 'running' ) , this . key ( 'processed' ) , this . key ( 'worker' , this . config . workerId , 'queue' ) , this . key ( 'owners' ) , this . testGroupTimeoutKey ( ) , Date . now ( ) / 1000 , this . useDynamicDeadline ( ) ) ;
109120 }
110121 async tryToReserveLostTest ( ) {
111- const lostTest = await this . client . reserveLost ( this . key ( 'running' ) , this . key ( 'completed' ) , this . key ( 'worker' , this . config . workerId , 'queue' ) , this . key ( 'owners' ) , Date . now ( ) / 1000 , this . config . timeout ) ;
122+ const lostTest = await this . client . reserveLost ( this . key ( 'running' ) , this . key ( 'completed' ) , this . key ( 'worker' , this . config . workerId , 'queue' ) , this . key ( 'owners' ) , this . testGroupTimeoutKey ( ) , Date . now ( ) / 1000 , this . config . timeout , this . useDynamicDeadline ( ) ) ;
112123 return lostTest ;
113124 }
114- async push ( tests ) {
125+ async push ( testSpecs ) {
126+ const tests = testSpecs . map ( ( testSpec ) => testSpec . name ) ;
127+ const testTimeoutMap = testSpecs . reduce ( ( acc , testSpec ) => {
128+ acc [ testSpec . name ] = testSpec . timeout ;
129+ return acc ;
130+ } , { } ) ;
115131 this . totalTestCount = tests . length ;
116132 this . isMaster = await this . client . setNX ( this . key ( 'master-status' ) , 'setup' ) ;
117133 if ( this . isMaster ) {
118134 await this . client
119135 . multi ( )
120136 . lPush ( this . key ( 'queue' ) , tests )
137+ . hSet ( this . testGroupTimeoutKey ( ) , testTimeoutMap )
121138 . set ( this . key ( 'total' ) , this . totalTestCount )
122139 . set ( this . key ( 'master-status' ) , 'ready' )
123140 . expire ( this . key ( 'queue' ) , this . config . redisTTL )
124141 . expire ( this . key ( 'total' ) , this . config . redisTTL )
125142 . expire ( this . key ( 'master-status' ) , this . config . redisTTL )
143+ . expire ( this . testGroupTimeoutKey ( ) , this . config . redisTTL )
126144 . exec ( ) ;
127145 }
128146 await this . client . sAdd ( this . key ( 'workers' ) , [ this . config . workerId ] ) ;
0 commit comments