-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(move-to-finished): consider addition of prioritized jobs when processing last active job #2176
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -624,10 +624,10 @@ describe('workers', function () { | |
await worker.close(); | ||
}); | ||
|
||
it('should processes jobs by priority', async () => { | ||
const normalPriority = []; | ||
const mediumPriority = []; | ||
const highPriority = []; | ||
it('should process jobs by priority', async () => { | ||
const normalPriority: Promise<Job>[] = []; | ||
const mediumPriority: Promise<Job>[] = []; | ||
const highPriority: Promise<Job>[] = []; | ||
|
||
let processor; | ||
|
||
|
@@ -669,14 +669,44 @@ describe('workers', function () { | |
const worker = new Worker(queueName, processor, { connection }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @roggervalf I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, probably in case of dragonfly its needed, ok let me add it back |
||
await worker.waitUntilReady(); | ||
|
||
// wait for all jobs to enter the queue and then start processing | ||
await Promise.all([normalPriority, mediumPriority, highPriority]); | ||
|
||
await processing; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by awaiting this line is sufficient |
||
|
||
await worker.close(); | ||
}); | ||
|
||
describe('when prioritized job is added while processing last active job', () => { | ||
it('should process prioritized job whithout delay', async function () { | ||
this.timeout(1000); | ||
await queue.add('test1', { p: 2 }, { priority: 2 }); | ||
let counter = 0; | ||
let processor; | ||
const processing = new Promise<void>((resolve, reject) => { | ||
processor = async (job: Job) => { | ||
try { | ||
if (job.name == 'test1') | ||
{await queue.add('test', { p: 2 }, { priority: 2 });} | ||
|
||
expect(job.id).to.be.ok; | ||
expect(job.data.p).to.be.eql(2); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
|
||
if (++counter === 2) { | ||
resolve(); | ||
} | ||
}; | ||
}); | ||
|
||
const worker = new Worker(queueName, processor, { connection }); | ||
await worker.waitUntilReady(); | ||
|
||
await processing; | ||
|
||
await worker.close(); | ||
}); | ||
}); | ||
|
||
it('process several jobs serially', async () => { | ||
let counter = 1; | ||
const maxJobs = 35; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grater -> greater