-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! forward port workarround for queue populator batch getting stuck
- Loading branch information
Showing
3 changed files
with
113 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const assert = require('assert'); | ||
const sinon = require('sinon'); | ||
|
||
const QueuePopulator = require('../../../lib/queuePopulator/QueuePopulator'); | ||
const { queueBatch } = require('../../../bin/queuePopulator'); | ||
|
||
describe('queuePopulator', () => { | ||
|
||
afterEach(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
describe('processLogEntries', () => { | ||
it('should reset batchInProgress if processLogEntries gets stuck', done => { | ||
const qp = new QueuePopulator({}, {}, {}, {}, {}, {}, {}, {}); | ||
const processLogEntries = sinon.stub(qp, 'processLogEntries').callsFake(options => { | ||
setTimeout(() => { | ||
options.onTimeout(); | ||
}, 1000); | ||
}); | ||
const taskStatus = { batchInProgress: false }; | ||
queueBatch(qp, taskStatus); | ||
assert.strictEqual(taskStatus.batchInProgress, true); | ||
assert(processLogEntries.calledOnce); | ||
setTimeout(() => { | ||
assert.strictEqual(taskStatus.batchInProgress, false); | ||
done(); | ||
}, 2000); | ||
}).timeout(4000); | ||
|
||
it('should reset batchInProgress when processLogEntries finishes', () => { | ||
const qp = new QueuePopulator({}, {}, {}, {}, {}, {}, {}, {}); | ||
const processLogEntries = sinon.stub(qp, 'processLogEntries').yields(); | ||
const taskStatus = { batchInProgress: false }; | ||
queueBatch(qp, taskStatus); | ||
assert(processLogEntries.calledOnce); | ||
assert.strictEqual(taskStatus.batchInProgress, false); | ||
}); | ||
|
||
it('should skip batch if one is currently in progress', () => { | ||
const qp = new QueuePopulator({}, {}, {}, {}, {}, {}, {}, {}); | ||
const processLogEntries = sinon.stub(qp, 'processLogEntries').yields(); | ||
const taskStatus = { batchInProgress: true }; | ||
queueBatch(qp, taskStatus); | ||
assert.strictEqual(taskStatus.batchInProgress, true); | ||
assert(processLogEntries.notCalled); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters