@@ -31,7 +31,7 @@ describe('Concurrency', () => {
31
31
} ) ;
32
32
33
33
it ( 'should run max concurrency for jobs added' , async ( ) => {
34
- const queue = new Queue ( queueName , { connection, concurrency : 1 , prefix } ) ;
34
+ const queue = new Queue ( queueName , { connection, prefix } ) ;
35
35
const numJobs = 15 ;
36
36
const jobsData : { name : string ; data : any } [ ] = [ ] ;
37
37
for ( let j = 0 ; j < numJobs ; j ++ ) {
@@ -42,7 +42,7 @@ describe('Concurrency', () => {
42
42
}
43
43
44
44
await queue . addBulk ( jobsData ) ;
45
-
45
+ await queue . setGlobalConcurrency ( 1 ) ;
46
46
const bar = new ProgressBar ( ':bar' , { total : numJobs } ) ;
47
47
48
48
let count = 0 ;
@@ -93,7 +93,7 @@ describe('Concurrency', () => {
93
93
} ) . timeout ( 16000 ) ;
94
94
95
95
it ( 'emits drained global event only once when worker is idle' , async function ( ) {
96
- const queue = new Queue ( queueName , { connection, concurrency : 1 , prefix } ) ;
96
+ const queue = new Queue ( queueName , { connection, prefix } ) ;
97
97
const worker = new Worker (
98
98
queueName ,
99
99
async ( ) => {
@@ -119,6 +119,7 @@ describe('Concurrency', () => {
119
119
{ name : 'test' , data : { foo : 'bar' } } ,
120
120
{ name : 'test' , data : { foo : 'baz' } } ,
121
121
] ) ;
122
+ await queue . setGlobalConcurrency ( 1 ) ;
122
123
123
124
await delay ( 4000 ) ;
124
125
@@ -138,11 +139,11 @@ describe('Concurrency', () => {
138
139
139
140
const queue = new Queue ( queueName , {
140
141
connection,
141
- concurrency : 1 ,
142
142
prefix,
143
143
} ) ;
144
144
const queueEvents = new QueueEvents ( queueName , { connection, prefix } ) ;
145
145
await queueEvents . waitUntilReady ( ) ;
146
+ await queue . setGlobalConcurrency ( 1 ) ;
146
147
147
148
const worker = new Worker (
148
149
queueName ,
@@ -222,11 +223,11 @@ describe('Concurrency', () => {
222
223
223
224
const queue = new Queue ( queueName , {
224
225
connection,
225
- concurrency : 1 ,
226
226
prefix,
227
227
} ) ;
228
228
const queueEvents = new QueueEvents ( queueName , { connection, prefix } ) ;
229
229
await queueEvents . waitUntilReady ( ) ;
230
+ await queue . setGlobalConcurrency ( 1 ) ;
230
231
231
232
const worker = new Worker (
232
233
queueName ,
@@ -304,7 +305,6 @@ describe('Concurrency', () => {
304
305
const flow = new FlowProducer ( { connection, prefix } ) ;
305
306
const queue = new Queue ( queueName , {
306
307
connection,
307
- concurrency : 1 ,
308
308
prefix,
309
309
} ) ;
310
310
@@ -317,6 +317,8 @@ describe('Concurrency', () => {
317
317
}
318
318
319
319
await queue . addBulk ( jobsData ) ;
320
+ await queue . setGlobalConcurrency ( 1 ) ;
321
+
320
322
const name = 'child-job' ;
321
323
322
324
await flow . add ( {
@@ -394,13 +396,13 @@ describe('Concurrency', () => {
394
396
const globalConcurrency = 2 ;
395
397
const queue = new Queue ( queueName , {
396
398
connection,
397
- concurrency : globalConcurrency ,
398
399
prefix,
399
400
} ) ;
400
401
401
402
for ( let j = 0 ; j < numJobs ; j ++ ) {
402
403
await queue . add ( 'test-stalled' , { foo : j % 2 } ) ;
403
404
}
405
+ await queue . setGlobalConcurrency ( globalConcurrency ) ;
404
406
405
407
const concurrency = 4 ;
406
408
@@ -486,7 +488,6 @@ describe('Concurrency', () => {
486
488
const globalConcurrency = 1 ;
487
489
const queue = new Queue ( queueName , {
488
490
connection,
489
- concurrency : globalConcurrency ,
490
491
prefix,
491
492
} ) ;
492
493
@@ -497,6 +498,7 @@ describe('Concurrency', () => {
497
498
{ attempts : 2 , backoff : 100 } ,
498
499
) ;
499
500
}
501
+ await queue . setGlobalConcurrency ( globalConcurrency ) ;
500
502
501
503
const concurrency = 10 ;
502
504
@@ -538,7 +540,6 @@ describe('Concurrency', () => {
538
540
const globalConcurrency = 1 ;
539
541
const queue = new Queue ( queueName , {
540
542
connection,
541
- concurrency : globalConcurrency ,
542
543
prefix,
543
544
} ) ;
544
545
@@ -549,6 +550,7 @@ describe('Concurrency', () => {
549
550
{ attempts : 2 , backoff : 0 } ,
550
551
) ;
551
552
}
553
+ await queue . setGlobalConcurrency ( globalConcurrency ) ;
552
554
553
555
const concurrency = 4 ;
554
556
@@ -591,9 +593,10 @@ describe('Concurrency', () => {
591
593
const globalConcurrency = 1 ;
592
594
const queue = new Queue ( queueName , {
593
595
connection,
594
- concurrency : globalConcurrency ,
595
596
prefix,
596
597
} ) ;
598
+ await queue . waitUntilReady ( ) ;
599
+ await queue . setGlobalConcurrency ( globalConcurrency ) ;
597
600
const worker = new Worker ( queueName , null , {
598
601
connection,
599
602
lockRenewTime : 200 ,
0 commit comments