@@ -266,6 +266,11 @@ describe('Test simple pool.', () => {
266
266
await expect ( await adjust ( { poolSize : 2 } ) ) . resolves ;
267
267
expect ( createRunners ) . not . toHaveBeenCalled ( ) ;
268
268
} ) ;
269
+
270
+ it ( 'Should not top up if pool size is invalid.' , async ( ) => {
271
+ await expect ( await adjust ( { poolSize : - 2 } ) ) . resolves ;
272
+ expect ( createRunners ) . not . toHaveBeenCalled ( ) ;
273
+ } ) ;
269
274
} ) ;
270
275
271
276
describe ( 'With GHES' , ( ) => {
@@ -368,6 +373,7 @@ describe('Test simple pool.', () => {
368
373
await expect ( await adjust ( { poolSize : - 1 } ) ) . resolves ;
369
374
expect ( createRunners ) . not . toHaveBeenCalled ( ) ;
370
375
} ) ;
376
+
371
377
// effective pool size is 8 (2 queued job with matching labels x 2 workflows x 2 accessible repositories)
372
378
it ( 'Should top up if there are more queued jobs with matching labels than idle runners.' , async ( ) => {
373
379
mockOctokit . actions . listWorkflowRunsForRepo . mockImplementation ( async ( { owner, repo } ) => [
@@ -420,6 +426,46 @@ describe('Test simple pool.', () => {
420
426
expect . anything ( ) ,
421
427
) ;
422
428
} ) ;
429
+
430
+ it ( 'Should top up the repository runners pool dynamically' , async ( ) => {
431
+ const runnerOwner = `${ ORG } /my-repo-1` ;
432
+ process . env . RUNNER_OWNER = runnerOwner ;
433
+ mockOctokit . actions . listWorkflowRunsForRepo . mockImplementation ( async ( { owner, repo } ) => [
434
+ {
435
+ repository : {
436
+ owner : { login : owner } ,
437
+ name : repo ,
438
+ } ,
439
+ id : 1 ,
440
+ attempt_number : 1 ,
441
+ } ,
442
+ {
443
+ repository : {
444
+ owner : { login : owner } ,
445
+ name : repo ,
446
+ } ,
447
+ id : 2 ,
448
+ attempt_number : 1 ,
449
+ } ,
450
+ ] ) ;
451
+ mockOctokit . actions . listJobsForWorkflowRunAttempt . mockImplementation ( async ( ) => [
452
+ {
453
+ status : 'queued' ,
454
+ labels : LABELS ,
455
+ } ,
456
+ {
457
+ status : 'queued' ,
458
+ labels : LABELS ,
459
+ } ,
460
+ ] ) ;
461
+ await expect ( await adjust ( { poolSize : - 1 } ) ) . resolves ;
462
+ expect ( createRunners ) . toHaveBeenCalledTimes ( 1 ) ;
463
+ expect ( createRunners ) . toHaveBeenCalledWith (
464
+ expect . objectContaining ( { runnerOwner, runnerType : 'Repo' } ) ,
465
+ expect . objectContaining ( { numberOfRunners : 2 } ) ,
466
+ expect . anything ( ) ,
467
+ ) ;
468
+ } ) ;
423
469
} ) ;
424
470
425
471
describe ( 'With Multiple Runner Owners' , ( ) => {
0 commit comments