Skip to content

Commit

Permalink
test(stalled_jobs): finetune params
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Apr 10, 2020
1 parent 37bca94 commit 2d3ee8f
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/test/test_stalled_jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ describe('stalled jobs', function() {
});

it('jobs not stalled while lock is extended', async function() {
this.timeout(10000);
this.timeout(5000);

const concurrency = 4;

const worker = new Worker(
queueName,
async job => {
return delay(5000);
return delay(4000);
},
{
lockDuration: 1000, // lockRenewTime would be half of it i.e. 500
lockDuration: 100, // lockRenewTime would be half of it i.e. 500
concurrency,
},
);
Expand All @@ -154,8 +154,6 @@ describe('stalled jobs', function() {
worker.on('active', after(concurrency, resolve));
});

await worker.waitUntilReady();

await Promise.all([
queue.add('test', { bar: 'baz' }),
queue.add('test', { bar1: 'baz1' }),
Expand All @@ -166,15 +164,14 @@ describe('stalled jobs', function() {
await allActive;

const queueScheduler = new QueueScheduler(queueName, {
stalledInterval: 100,
stalledInterval: 50,
});
await queueScheduler.waitUntilReady();

const allStalled = new Promise(resolve => {
queueScheduler.on('stalled', after(concurrency, resolve));
});
const allStalled = new Promise(resolve =>
queueScheduler.on('stalled', after(concurrency, resolve)),
);

await delay(2000); // let worker to extend lock for several times
await delay(500); // Wait for jobs to become active

const active = await queue.getActiveCount();
expect(active).to.be.equal(4);
Expand Down

0 comments on commit 2d3ee8f

Please sign in to comment.