rethinkdb-job-queue
Advanced tools
Comparing version 0.0.7 to 0.0.8
# `rethinkdb-job-queue` Change log | ||
## v0.0.7 / 2016-08 | ||
## v0.0.8 / 2016-09-09 | ||
* Replaced `node-uuid` dependency with `uuid` package. | ||
* Renamed `dateRetry` to `dateEnable`. | ||
* Updated `is.date()` to remove `moment.isDate()`. | ||
* Added 'Delayed Job' tests to queue-process tests. | ||
## v0.0.7 / 2016-08-23 | ||
* Fixed next() calls. | ||
@@ -6,0 +13,0 @@ * Minor refactor. |
@@ -7,5 +7,5 @@ 'use strict'; | ||
function createIndexActiveDateRetry(q) { | ||
logger('createIndexActiveDateRetry'); | ||
var indexName = enums.index.indexActiveDateRetry; | ||
function createIndexActiveDateEnable(q) { | ||
logger('createIndexActiveDateEnable'); | ||
var indexName = enums.index.indexActiveDateEnable; | ||
return Promise.resolve().then(function () { | ||
@@ -18,3 +18,3 @@ return q.r.db(q.db).table(q.name).indexList().contains(indexName).run(); | ||
return q.r.db(q.db).table(q.name).indexCreate(indexName, function (row) { | ||
return q.r.branch(row('status').eq('active'), row('dateRetry'), null); | ||
return q.r.branch(row('status').eq('active'), row('dateEnable'), null); | ||
}).run(); | ||
@@ -34,3 +34,3 @@ }); | ||
return q.r.db(q.db).table(q.name).indexCreate(indexName, function (row) { | ||
return q.r.branch(row('status').eq('added'), [row('priority'), row('dateRetry'), row('dateCreated')], row('status').eq('failed'), [row('priority'), row('dateRetry'), row('dateCreated')], null); | ||
return q.r.branch(row('status').eq('added'), [row('priority'), row('dateEnable'), row('dateCreated')], row('status').eq('failed'), [row('priority'), row('dateEnable'), row('dateCreated')], null); | ||
}).run(); | ||
@@ -57,3 +57,3 @@ }); | ||
logger('assertIndex'); | ||
return Promise.all([createIndexActiveDateRetry(q), createIndexInactivePriorityDateCreated(q), createIndexFinishedDateFinished(q)]).then(function (indexCreateResult) { | ||
return Promise.all([createIndexActiveDateEnable(q), createIndexInactivePriorityDateCreated(q), createIndexFinishedDateFinished(q)]).then(function (indexCreateResult) { | ||
logger('Waiting for index...'); | ||
@@ -60,0 +60,0 @@ return q.r.db(q.db).table(q.name).indexWait().run(); |
@@ -16,3 +16,3 @@ 'use strict'; | ||
return Promise.resolve().then(function () { | ||
return q.r.db(q.db).table(q.name).orderBy({ index: enums.index.indexActiveDateRetry }).filter(q.r.row('dateRetry').lt(q.r.now())).update({ | ||
return q.r.db(q.db).table(q.name).orderBy({ index: enums.index.indexActiveDateEnable }).filter(q.r.row('dateEnable').lt(q.r.now())).update({ | ||
status: q.r.branch(q.r.row('retryCount').lt(q.r.row('retryMax')), enums.status.failed, enums.status.terminated), | ||
@@ -28,3 +28,3 @@ dateFinished: q.r.now(), | ||
message: 'Master: ' + enums.message.failed, | ||
dateRetry: q.r.row('dateRetry') | ||
dateEnable: q.r.row('dateEnable') | ||
}), | ||
@@ -31,0 +31,0 @@ queueId: q.id |
@@ -62,3 +62,3 @@ 'use strict'; | ||
index: { | ||
indexActiveDateRetry: 'indexActiveDateRetry', | ||
indexActiveDateEnable: 'indexActiveDateEnable', | ||
indexInactivePriorityDateCreated: 'indexInactivePriorityDateCreated', | ||
@@ -65,0 +65,0 @@ indexFinishedDateFinished: 'indexFinishedDateFinished' |
'use strict'; | ||
var logger = require('./logger')(module); | ||
var moment = require('moment'); | ||
var enums = require('./enums'); | ||
@@ -43,5 +42,5 @@ var uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; | ||
module.exports.date = function isDate(value) { | ||
var isDate = module.exports.date = function isDate(value) { | ||
logger('isDate', value); | ||
return moment.isDate(value); | ||
return value instanceof Date || Object.prototype.toString.call(value) === '[object Date]'; | ||
}; | ||
@@ -83,3 +82,3 @@ | ||
} | ||
if (!moment.isDate(value.dateCreated)) { | ||
if (!isDate(value.dateCreated)) { | ||
return false; | ||
@@ -86,0 +85,0 @@ } |
@@ -94,7 +94,7 @@ 'use strict'; | ||
} | ||
if (!moment.isDate(j.dateCreated)) { | ||
if (!is.date(j.dateCreated)) { | ||
detail = 'Job dateCreated: ' + j.dateCreated; | ||
} | ||
if (!moment.isDate(j.dateRetry)) { | ||
detail = 'Job dateRetry: ' + j.dateRetry; | ||
if (!is.date(j.dateEnable)) { | ||
detail = 'Job dateEnable: ' + j.dateEnable; | ||
} | ||
@@ -101,0 +101,0 @@ if (j.progress < 0 || j.progress > 100) { |
@@ -25,3 +25,3 @@ 'use strict'; | ||
progress: percent, | ||
dateRetry: job.q.r.now().add(job.q.r.row('timeout')).add(job.q.r.row('retryDelay').mul(job.q.r.row('retryCount'))) | ||
dateEnable: job.q.r.now().add(job.q.r.row('timeout')).add(job.q.r.row('retryDelay').mul(job.q.r.row('retryCount'))) | ||
}).run(); | ||
@@ -28,0 +28,0 @@ }).then(function (updateResult) { |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var logger = require('./logger')(module); | ||
var uuid = require('node-uuid'); | ||
var uuid = require('uuid'); | ||
var moment = require('moment'); | ||
@@ -51,3 +51,3 @@ var enums = require('./enums'); | ||
this.dateCreated = now; | ||
this.dateRetry = now; | ||
this.dateEnable = now; | ||
this.dateStarted; | ||
@@ -54,0 +54,0 @@ this.dateFinished; |
@@ -17,6 +17,6 @@ 'use strict'; | ||
return Promise.resolve().then(function () { | ||
return q.r.table(q.name).orderBy({ index: enums.index.indexInactivePriorityDateCreated }).limit(quantity).filter(q.r.row('dateRetry').le(q.r.now())).update({ | ||
return q.r.table(q.name).orderBy({ index: enums.index.indexInactivePriorityDateCreated }).limit(quantity).filter(q.r.row('dateEnable').le(q.r.now())).update({ | ||
status: enums.status.active, | ||
dateStarted: q.r.now(), | ||
dateRetry: q.r.now().add(q.r.row('timeout')).add(q.r.row('retryDelay').mul(q.r.row('retryCount'))), | ||
dateEnable: q.r.now().add(q.r.row('timeout')).add(q.r.row('retryDelay').mul(q.r.row('retryCount'))), | ||
queueId: q.id, | ||
@@ -23,0 +23,0 @@ log: q.r.row('log').append({ |
@@ -99,3 +99,6 @@ 'use strict'; | ||
var jobTick = function jobTick(q) { | ||
logger('jobTick', 'Running: [' + q.running + ']'); | ||
logger('jobTick'); | ||
logger('Running: [' + q.running + ']'); | ||
logger('_getNextJobActive [' + q._getNextJobActive + ']'); | ||
logger('_getNextJobCalled [' + q._getNextJobCalled + ']'); | ||
if (q._getNextJobActive) { | ||
@@ -102,0 +105,0 @@ q._getNextJobCalled = true; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var EventEmitter = require('events').EventEmitter; | ||
var uuid = require('node-uuid'); | ||
var uuid = require('uuid'); | ||
var Promise = require('bluebird'); | ||
@@ -39,3 +39,3 @@ var is = require('./is'); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Queue).call(this)); | ||
var _this = _possibleConstructorReturn(this, (Queue.__proto__ || Object.getPrototypeOf(Queue)).call(this)); | ||
@@ -42,0 +42,0 @@ logger('Queue Constructor', options); |
{ | ||
"name": "rethinkdb-job-queue", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A persistent job or task queue backed by RethinkDB.", | ||
@@ -48,15 +48,15 @@ "main": "index.js", | ||
"dependencies": { | ||
"bluebird": "^3.4.1", | ||
"bluebird": "^3.4.6", | ||
"debug": "^2.2.0", | ||
"moment": "^2.14.1", | ||
"node-uuid": "^1.4.7", | ||
"rethinkdbdash": "^2.3.20" | ||
"rethinkdbdash": "^2.3.21", | ||
"uuid": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.11.4", | ||
"babel-cli": "^6.14.0", | ||
"babel-eslint": "^6.1.2", | ||
"babel-preset-es2015": "^6.13.2", | ||
"babel-preset-es2015": "^6.14.0", | ||
"npm-check-updates": "^2.8.0", | ||
"proxyquire": "^1.7.10", | ||
"standard": "^7.1.2", | ||
"standard": "^8.0.0", | ||
"tap-spec": "^4.1.1", | ||
@@ -63,0 +63,0 @@ "tape": "^4.6.0" |
@@ -165,3 +165,3 @@ # Introduction | ||
- The date management library [moment][moment-url]. | ||
- The UUID package [node-uuid][uuid-url] by [Robert Kieffer][broofa-url]. | ||
- The [uuid][uuid-url] package. | ||
@@ -188,4 +188,3 @@ This list could go on... | ||
[moment-url]: http://momentjs.com/ | ||
[uuid-url]: https://github.com/broofa/node-uuid | ||
[broofa-url]: https://github.com/broofa | ||
[uuid-url]: https://www.npmjs.com/package/uuid | ||
[bithound-overall-image]: https://www.bithound.io/github/grantcarthew/node-rethinkdb-job-queue/badges/score.svg | ||
@@ -192,0 +191,0 @@ [bithound-overall-url]: https://www.bithound.io/github/grantcarthew/node-rethinkdb-job-queue |
@@ -121,5 +121,5 @@ const test = require('tape') | ||
t.equal(reviewedRetryCount0Job[0].priority, 'normal', 'Reviewed job 1 is normal priority') | ||
t.ok(moment.isDate(reviewedRetryCount0Job[0].dateFinished), 'Reviewed job 1 dateFinished is a date') | ||
t.ok(is.date(reviewedRetryCount0Job[0].dateFinished), 'Reviewed job 1 dateFinished is a date') | ||
t.equal(reviewedRetryCount0Job[0].retryCount, 1, 'Reviewed job 1 retryCount is 1') | ||
t.ok(moment.isDate(reviewedRetryCount0Job[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(reviewedRetryCount0Job[0].log[1].date), 'Log date is a date') | ||
t.equal(reviewedRetryCount0Job[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -135,5 +135,5 @@ t.equal(reviewedRetryCount0Job[0].log[1].type, enums.log.warning, 'Log type is warning') | ||
t.equal(reviewedRetryCount1Job[0].priority, 'normal', 'Reviewed job 2 is normal priority') | ||
t.ok(moment.isDate(reviewedRetryCount1Job[0].dateFinished), 'Reviewed job 2 dateFinished is a date') | ||
t.ok(is.date(reviewedRetryCount1Job[0].dateFinished), 'Reviewed job 2 dateFinished is a date') | ||
t.equal(reviewedRetryCount1Job[0].retryCount, 1, 'Reviewed job 2 retryCount is 1') | ||
t.ok(moment.isDate(reviewedRetryCount1Job[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(reviewedRetryCount1Job[0].log[1].date), 'Log date is a date') | ||
t.equal(reviewedRetryCount1Job[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -143,3 +143,3 @@ t.equal(reviewedRetryCount1Job[0].log[1].type, enums.log.error, 'Log type is error') | ||
t.ok(reviewedRetryCount1Job[0].log[1].retryCount >= 0, 'Log retryCount is valid') | ||
t.ok(moment.isDate(reviewedRetryCount1Job[0].log[1].dateRetry), 'Log dateRetry is a date') | ||
t.ok(is.date(reviewedRetryCount1Job[0].log[1].dateEnable), 'Log dateEnable is a date') | ||
t.ok(reviewedRetryCount1Job[0].log[1].message, 'Log message is present') | ||
@@ -146,0 +146,0 @@ t.ok(!reviewedRetryCount1Job[0].log[1].data, 'Log data is null') |
const test = require('tape') | ||
const moment = require('moment') | ||
const uuid = require('node-uuid') | ||
const uuid = require('uuid') | ||
const is = require('../src/is') | ||
@@ -5,0 +5,0 @@ const enums = require('../src/enums') |
@@ -56,3 +56,3 @@ const test = require('tape') | ||
t.equal(jobWithLog1[0].log.length, 2, 'Log 1 exists on retrieved job') | ||
t.ok(moment.isDate(jobWithLog1[0].log[1].date), 'Log 1 date is a date') | ||
t.ok(is.date(jobWithLog1[0].log[1].date), 'Log 1 date is a date') | ||
t.equal(jobWithLog1[0].log[1].queueId, q.id, 'Log 1 queueId is valid') | ||
@@ -74,3 +74,3 @@ t.equal(jobWithLog1[0].log[1].type, enums.log.information, 'Log 1 type is information') | ||
t.equal(jobWithLog2[0].log.length, 3, 'Log 2 exists on retrieved job') | ||
t.ok(moment.isDate(jobWithLog2[0].log[2].date), 'Log 2 date is a date') | ||
t.ok(is.date(jobWithLog2[0].log[2].date), 'Log 2 date is a date') | ||
t.equal(jobWithLog2[0].log[2].queueId, q.id, 'Log 2 queueId is valid') | ||
@@ -77,0 +77,0 @@ t.equal(jobWithLog2[0].log[2].type, enums.log.information, 'Log 2 type is information') |
@@ -59,7 +59,7 @@ const test = require('tape') | ||
t.equal(updatedJob[0].status, enums.status.completed, 'Job status is completed') | ||
t.ok(moment.isDate(updatedJob[0].dateFinished), 'Job dateFinished is a date') | ||
t.ok(is.date(updatedJob[0].dateFinished), 'Job dateFinished is a date') | ||
t.equal(updatedJob[0].progress, 100, 'Job progress is 100') | ||
t.equal(updatedJob[0].queueId, q.id, 'Job queueId is valid') | ||
t.equal(updatedJob[0].log.length, 2, 'Job log exists') | ||
t.ok(moment.isDate(updatedJob[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(updatedJob[0].log[1].date), 'Log date is a date') | ||
t.equal(updatedJob[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -66,0 +66,0 @@ t.equal(updatedJob[0].log[1].type, enums.log.information, 'Log type is information') |
@@ -75,5 +75,5 @@ const test = require('tape') | ||
t.equal(retry1[0].queueId, q.id, 'Job queueId is valid') | ||
t.ok(moment.isDate(retry1[0].dateFinished), 'Job dateFinished is a date') | ||
t.ok(is.date(retry1[0].dateFinished), 'Job dateFinished is a date') | ||
t.equal(retry1[0].log.length, 2, 'Job has 1 log entry') | ||
t.ok(moment.isDate(retry1[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(retry1[0].log[1].date), 'Log date is a date') | ||
t.equal(retry1[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -98,5 +98,5 @@ t.equal(retry1[0].log[1].type, enums.log.warning, 'Log type is warning') | ||
t.equal(retry2[0].queueId, q.id, 'Job queueId is valid') | ||
t.ok(moment.isDate(retry2[0].dateFinished), 'Job dateFinished is a date') | ||
t.ok(is.date(retry2[0].dateFinished), 'Job dateFinished is a date') | ||
t.equal(retry2[0].log.length, 3, 'Job has 2 log entries') | ||
t.ok(moment.isDate(retry2[0].log[2].date), 'Log date is a date') | ||
t.ok(is.date(retry2[0].log[2].date), 'Log date is a date') | ||
t.equal(retry2[0].log[2].queueId, q.id, 'Log queueId is valid') | ||
@@ -122,5 +122,5 @@ t.equal(retry2[0].log[2].type, enums.log.warning, 'Log type is warning') | ||
t.equal(retry3[0].queueId, q.id, 'Job queueId is valid') | ||
t.ok(moment.isDate(retry3[0].dateFinished), 'Job dateFinished is a date') | ||
t.ok(is.date(retry3[0].dateFinished), 'Job dateFinished is a date') | ||
t.equal(retry3[0].log.length, 4, 'Job has 3 log entries') | ||
t.ok(moment.isDate(retry3[0].log[3].date), 'Log date is a date') | ||
t.ok(is.date(retry3[0].log[3].date), 'Log date is a date') | ||
t.equal(retry3[0].log[3].queueId, q.id, 'Log queueId is valid') | ||
@@ -146,5 +146,5 @@ t.equal(retry3[0].log[3].type, enums.log.warning, 'Log type is warning') | ||
t.equal(failed[0].queueId, q.id, 'Job queueId is valid') | ||
t.ok(moment.isDate(failed[0].dateFinished), 'Job dateFinished is a date') | ||
t.ok(is.date(failed[0].dateFinished), 'Job dateFinished is a date') | ||
t.equal(failed[0].log.length, 5, 'Job has 4 log entries') | ||
t.ok(moment.isDate(failed[0].log[4].date), 'Log date is a date') | ||
t.ok(is.date(failed[0].log[4].date), 'Log date is a date') | ||
t.equal(failed[0].log[4].queueId, q.id, 'Log queueId is valid') | ||
@@ -151,0 +151,0 @@ t.equal(failed[0].log[4].type, enums.log.error, 'Log type is error') |
@@ -5,3 +5,3 @@ const test = require('tape') | ||
const Job = require('../src/job') | ||
const uuid = require('node-uuid') | ||
const uuid = require('uuid') | ||
@@ -104,4 +104,4 @@ module.exports = function () { | ||
job = new Job(mockQueue) | ||
job.dateRetry = {} | ||
t.throws(() => { jobParse.job(job) }, 'Invalid job dateRetry throws an exception') | ||
job.dateEnable = {} | ||
t.throws(() => { jobParse.job(job) }, 'Invalid job dateEnable throws an exception') | ||
job = new Job(mockQueue) | ||
@@ -108,0 +108,0 @@ job.progress = 101 |
@@ -37,3 +37,3 @@ const test = require('tape') | ||
let tempDateRetry = job.dateRetry | ||
let tempDateEnable = job.dateEnable | ||
return q.addJob(job).then((savedJob) => { | ||
@@ -55,5 +55,5 @@ t.equal(savedJob[0].id, job.id, 'Job saved successfully') | ||
t.ok( | ||
moment(updatedJob[0].dateRetry).isBetween(moment(tempDateRetry), | ||
moment(updatedJob[0].dateEnable).isBetween(moment(tempDateEnable), | ||
moment().add(updatedJob[0].timeout + 2, 'seconds')), | ||
'Job dateRetry updated successfully' | ||
'Job dateEnable updated successfully' | ||
) | ||
@@ -68,5 +68,5 @@ updatedJob[0].status = enums.status.active | ||
t.ok( | ||
moment(updatedJob[0].dateRetry).isBetween(moment(tempDateRetry), | ||
moment(updatedJob[0].dateEnable).isBetween(moment(tempDateEnable), | ||
moment().add((updatedJob[0].timeout + 2) + updatedJob[0].retryDelay, 'seconds')), | ||
'Job dateRetry updated successfully' | ||
'Job dateEnable updated successfully' | ||
) | ||
@@ -73,0 +73,0 @@ updatedJob[0].status = enums.status.active |
@@ -69,4 +69,4 @@ const test = require('tape') | ||
t.equal(newJob.log.length, 0, 'New job log is an empty array') | ||
t.ok(moment.isDate(newJob.dateCreated), 'New job dateCreated is a date') | ||
t.ok(moment.isDate(newJob.dateRetry), 'New job dateRetry is a date') | ||
t.ok(is.date(newJob.dateCreated), 'New job dateCreated is a date') | ||
t.ok(is.date(newJob.dateEnable), 'New job dateEnable is a date') | ||
@@ -87,3 +87,3 @@ // ---------- Clean Job Tests ---------- | ||
t.equal(cleanJob.dateCreated, newJob.dateCreated, 'Clean job dateCreated is valid') | ||
t.equal(cleanJob.dateRetry, newJob.dateRetry, 'Clean job dateRetry is valid') | ||
t.equal(cleanJob.dateEnable, newJob.dateEnable, 'Clean job dateEnable is valid') | ||
t.equal(cleanJob.progress, newJob.progress, 'Clean job progress is valid') | ||
@@ -100,3 +100,3 @@ t.equal(cleanJob.queueId, newJob.queueId, 'Clean job progress is valid') | ||
t.equal(typeof log, 'object', 'Job createLog returns a log object') | ||
t.ok(moment.isDate(log.date), 'Log date is a date') | ||
t.ok(is.date(log.date), 'Log date is a date') | ||
t.equal(log.queueId, q.id, 'Log queueId is valid') | ||
@@ -133,3 +133,3 @@ t.equal(log.type, enums.log.information, 'Log type is information') | ||
t.equal(newJobFromData.dateCreated, savedJob.dateCreated, 'Clean job dateCreated is valid') | ||
t.equal(newJobFromData.dateRetry, savedJob.dateRetry, 'Clean job dateRetry is valid') | ||
t.equal(newJobFromData.dateEnable, savedJob.dateEnable, 'Clean job dateEnable is valid') | ||
t.equal(newJobFromData.progress, savedJob.progress, 'New job from data progress is valid') | ||
@@ -147,3 +147,3 @@ t.equal(newJobFromData.queueId, q.id, 'New job from data queueId is valid') | ||
t.equal(jobsFromDb[0].log.length, 2, 'Job log exists') | ||
t.ok(moment.isDate(jobsFromDb[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(jobsFromDb[0].log[1].date), 'Log date is a date') | ||
t.equal(jobsFromDb[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -150,0 +150,0 @@ t.equal(jobsFromDb[0].log[1].type, enums.log.information, 'Log type is information') |
@@ -41,3 +41,3 @@ const test = require('tape') | ||
}).then((jobsFromDb) => { | ||
t.ok(moment.isDate(jobsFromDb[0].log[0].date), 'Log job 1 date is a date') | ||
t.ok(is.date(jobsFromDb[0].log[0].date), 'Log job 1 date is a date') | ||
t.equal(jobsFromDb[0].log[0].queueId, q.id, 'Log job 1 queueId is valid') | ||
@@ -58,3 +58,3 @@ t.equal(jobsFromDb[0].log[0].type, enums.log.information, 'Log job 1 type is information') | ||
}).then((jobsFromDb2) => { | ||
t.ok(moment.isDate(jobsFromDb2[0].log[0].date), 'Log job 2 date is a date') | ||
t.ok(is.date(jobsFromDb2[0].log[0].date), 'Log job 2 date is a date') | ||
t.equal(jobsFromDb2[0].log[0].queueId, q.id, 'Log job 2 queueId is valid') | ||
@@ -67,3 +67,3 @@ t.equal(jobsFromDb2[0].log[0].type, enums.log.information, 'Log job 2 type is information') | ||
}).then((jobsFromDb3) => { | ||
t.ok(moment.isDate(jobsFromDb3[0].log[0].date), 'Log job 3 date is a date') | ||
t.ok(is.date(jobsFromDb3[0].log[0].date), 'Log job 3 date is a date') | ||
t.equal(jobsFromDb3[0].log[0].queueId, q.id, 'Log job 3 queueId is valid') | ||
@@ -70,0 +70,0 @@ t.equal(jobsFromDb3[0].log[0].type, enums.log.information, 'Log job 3 type is information') |
@@ -69,6 +69,6 @@ const test = require('tape') | ||
t.equal(cancelledJob[0].status, enums.status.cancelled, 'Job status is cancelled') | ||
t.ok(moment.isDate(cancelledJob[0].dateFinished), 'Job dateFinished is a date') | ||
t.ok(is.date(cancelledJob[0].dateFinished), 'Job dateFinished is a date') | ||
t.equal(cancelledJob[0].queueId, q.id, 'Job queueId is valid') | ||
t.equal(cancelledJob[0].log.length, 2, 'Job log exists') | ||
t.ok(moment.isDate(cancelledJob[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(cancelledJob[0].log[1].date), 'Log date is a date') | ||
t.equal(cancelledJob[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -75,0 +75,0 @@ t.equal(cancelledJob[0].log[1].type, enums.log.information, 'Log type is information') |
@@ -94,3 +94,3 @@ const test = require('tape') | ||
t.equals(failed[0].id, jobFailed.id, 'Failed status job1 returned first') | ||
t.ok(moment.isDate(failed[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(failed[0].log[1].date), 'Log date is a date') | ||
t.equal(failed[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -104,3 +104,3 @@ t.equal(failed[0].log[1].type, enums.log.information, 'Log type is information') | ||
t.equals(highest[0].id, jobHighest.id, 'Highest status job returned third') | ||
t.ok(moment.isDate(highest[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(highest[0].log[1].date), 'Log date is a date') | ||
t.equal(highest[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -114,3 +114,3 @@ t.equal(highest[0].log[1].type, enums.log.information, 'Log type is information') | ||
t.equals(high[0].id, jobHigh.id, 'High status job returned fourth') | ||
t.ok(moment.isDate(high[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(high[0].log[1].date), 'Log date is a date') | ||
t.equal(high[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -124,3 +124,3 @@ t.equal(high[0].log[1].type, enums.log.information, 'Log type is information') | ||
t.equals(medium[0].id, jobMedium.id, 'Medium status job returned fifth') | ||
t.ok(moment.isDate(medium[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(medium[0].log[1].date), 'Log date is a date') | ||
t.equal(medium[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -134,3 +134,3 @@ t.equal(medium[0].log[1].type, enums.log.information, 'Log type is information') | ||
t.equals(normal[0].id, jobNormal.id, 'Normal status job returned sixth') | ||
t.ok(moment.isDate(normal[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(normal[0].log[1].date), 'Log date is a date') | ||
t.equal(normal[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -144,3 +144,3 @@ t.equal(normal[0].log[1].type, enums.log.information, 'Log type is information') | ||
t.equals(low[0].id, jobLow.id, 'Low status job returned seventh') | ||
t.ok(moment.isDate(low[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(low[0].log[1].date), 'Log date is a date') | ||
t.equal(low[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -154,3 +154,3 @@ t.equal(low[0].log[1].type, enums.log.information, 'Log type is information') | ||
t.equals(lowest[0].id, jobLowest.id, 'Lowest status job returned last') | ||
t.ok(moment.isDate(lowest[0].log[1].date), 'Log date is a date') | ||
t.ok(is.date(lowest[0].log[1].date), 'Log date is a date') | ||
t.equal(lowest[0].log[1].queueId, q.id, 'Log queueId is valid') | ||
@@ -188,3 +188,3 @@ t.equal(lowest[0].log[1].type, enums.log.information, 'Log type is information') | ||
t.equals(group1[0].status, enums.status.active, 'Returned job is active status') | ||
t.ok(moment.isDate(group1[0].dateStarted), 'Returned job dateStarted is a date') | ||
t.ok(is.date(group1[0].dateStarted), 'Returned job dateStarted is a date') | ||
q._running = 1 | ||
@@ -195,5 +195,5 @@ return queueGetNextJob(q) | ||
t.equals(group2[0].status, enums.status.active, 'Returned job 1 is active status') | ||
t.ok(moment.isDate(group2[0].dateStarted), 'Returned job 1 dateStarted is a date') | ||
t.ok(is.date(group2[0].dateStarted), 'Returned job 1 dateStarted is a date') | ||
t.equals(group2[0].status, enums.status.active, 'Returned job 2 is active status') | ||
t.ok(moment.isDate(group2[1].dateStarted), 'Returned job 2 dateStarted is a date') | ||
t.ok(is.date(group2[1].dateStarted), 'Returned job 2 dateStarted is a date') | ||
q._running = 0 | ||
@@ -204,7 +204,7 @@ return queueGetNextJob(q) | ||
t.equals(group3[0].status, enums.status.active, 'Returned job 1 is active status') | ||
t.ok(moment.isDate(group3[0].dateStarted), 'Returned job 1 dateStarted is a date') | ||
t.ok(is.date(group3[0].dateStarted), 'Returned job 1 dateStarted is a date') | ||
t.equals(group3[0].status, enums.status.active, 'Returned job 2 is active status') | ||
t.ok(moment.isDate(group3[1].dateStarted), 'Returned job 2 dateStarted is a date') | ||
t.ok(is.date(group3[1].dateStarted), 'Returned job 2 dateStarted is a date') | ||
t.equals(group3[0].status, enums.status.active, 'Returned job 3 is active status') | ||
t.ok(moment.isDate(group3[2].dateStarted), 'Returned job 3 dateStarted is a date') | ||
t.ok(is.date(group3[2].dateStarted), 'Returned job 3 dateStarted is a date') | ||
return queueGetNextJob(q) | ||
@@ -214,9 +214,9 @@ }).then((group4) => { | ||
t.equals(group4[0].status, enums.status.active, 'Returned job is active status') | ||
t.ok(moment.isDate(group4[0].dateStarted), 'Returned job dateStarted is a date') | ||
t.ok(is.date(group4[0].dateStarted), 'Returned job dateStarted is a date') | ||
// ---------- Testing dateRetry Values ---------- | ||
t.comment('queue-get-next-job: dateRetry Values') | ||
// ---------- Testing dateEnable Values ---------- | ||
t.comment('queue-get-next-job: dateEnable Values') | ||
retryJobs = q.createJob(2).map(j => j) | ||
retryJobs[0].dateRetry = moment().add(100, 'seconds').toDate() | ||
retryJobs[1].dateRetry = moment().add(-100, 'seconds').toDate() | ||
retryJobs[0].dateEnable = moment().add(100, 'seconds').toDate() | ||
retryJobs[1].dateEnable = moment().add(-100, 'seconds').toDate() | ||
return q.addJob(retryJobs) | ||
@@ -227,16 +227,16 @@ }).then((retrySavedJobs) => { | ||
}).then((retryGet) => { | ||
t.equal(retryGet.length, 1, 'Only one job available based on dateRetry') | ||
t.equal(retryGet.length, 1, 'Only one job available based on dateEnable') | ||
t.equal(retryGet[0].id, retryJobs[1].id, 'Retry job valid') | ||
// ---------- Testing dateRetry with retryCount ---------- | ||
t.comment('queue-get-next-job: dateRetry with retryCount') | ||
// ---------- Testing dateEnable with retryCount ---------- | ||
t.comment('queue-get-next-job: dateEnable with retryCount') | ||
retryJobs = q.createJob(4).map(j => j) | ||
retryJobs[0].retryCount = 0 | ||
retryJobs[0].dateRetry = moment().add(-100, 'seconds').toDate() | ||
retryJobs[0].dateEnable = moment().add(-100, 'seconds').toDate() | ||
retryJobs[1].retryCount = 1 | ||
retryJobs[1].dateRetry = moment().add(-200, 'seconds').toDate() | ||
retryJobs[1].dateEnable = moment().add(-200, 'seconds').toDate() | ||
retryJobs[2].retryCount = 2 | ||
retryJobs[2].dateRetry = moment().add(-300, 'seconds').toDate() | ||
retryJobs[2].dateEnable = moment().add(-300, 'seconds').toDate() | ||
retryJobs[3].retryCount = 3 | ||
retryJobs[3].dateRetry = moment().add(-400, 'seconds').toDate() | ||
retryJobs[3].dateEnable = moment().add(-400, 'seconds').toDate() | ||
return q.addJob(retryJobs) | ||
@@ -248,3 +248,3 @@ }).then((retrySavedJobs) => { | ||
retryGet2.sort((a, b) => { | ||
if (moment(a.dateRetry).isSameOrBefore(b.dateRetry)) return -1 | ||
if (moment(a.dateEnable).isSameOrBefore(b.dateEnable)) return -1 | ||
return 1 | ||
@@ -254,6 +254,6 @@ }) | ||
let ids = retryGet2.map(j => j.id) | ||
t.ok(!ids.includes(retryJobs[0].id), 'Retrieved in dateRetry order successfully') | ||
t.ok(moment().isBefore(retryGet2[0].dateRetry), 'dateRetry for first job is valid') | ||
t.ok(moment(retryGet2[0].dateRetry).isBefore(retryGet2[1].dateRetry), 'dateRetry for second job is valid') | ||
t.ok(moment(retryGet2[1].dateRetry).isBefore(retryGet2[2].dateRetry), 'dateRetry for third job is valid') | ||
t.ok(!ids.includes(retryJobs[0].id), 'Retrieved in dateEnable order successfully') | ||
t.ok(moment().isBefore(retryGet2[0].dateEnable), 'dateEnable for first job is valid') | ||
t.ok(moment(retryGet2[0].dateEnable).isBefore(retryGet2[1].dateEnable), 'dateEnable for second job is valid') | ||
t.ok(moment(retryGet2[1].dateEnable).isBefore(retryGet2[2].dateEnable), 'dateEnable for third job is valid') | ||
return queueGetNextJob(q) | ||
@@ -260,0 +260,0 @@ }).then((retryGet3) => { |
@@ -19,4 +19,3 @@ const test = require('tape') | ||
// ---------- Test Setup ---------- | ||
const q = new Queue(testOptions.master(5)) | ||
dbReview.disable(q) | ||
const q = new Queue(testOptions.default()) | ||
@@ -30,3 +29,3 @@ let jobs | ||
let reviewedEventCount = 0 | ||
const reviewedEventTotal = 7 | ||
const reviewedEventTotal = 2 | ||
function reviewedEventHandler (replaceCount) { | ||
@@ -55,3 +54,3 @@ if (testEvents) { | ||
let processingEventCount = 0 | ||
const processingEventTotal = 36 | ||
const processingEventTotal = 37 | ||
function processingEventHandler (jobId) { | ||
@@ -74,3 +73,3 @@ if (testEvents) { | ||
let completedEventCount = 0 | ||
const completedEventTotal = 31 | ||
const completedEventTotal = 32 | ||
function completedEventHandler (jobId) { | ||
@@ -93,3 +92,3 @@ if (testEvents) { | ||
let idleEventCount = 0 | ||
const idleEventTotal = 12 | ||
const idleEventTotal = 11 | ||
function idleEventHandler (qid) { | ||
@@ -146,2 +145,6 @@ if (testEvents) { | ||
const summaryCompleted = 32 | ||
const summaryCancelled = 1 | ||
const summaryTerminated = 1 | ||
let testTimes = false | ||
@@ -156,3 +159,3 @@ let tryCount = 0 | ||
'seconds') | ||
t.ok(moment(job.dateRetry).isBefore(testDate, 'seconds'), 'Job dateRetry is valid') | ||
t.ok(moment(job.dateEnable).isBefore(testDate, 'seconds'), 'Job dateEnable is valid') | ||
tryCount++ | ||
@@ -257,5 +260,5 @@ } | ||
}).delay(5200).then(() => { | ||
dbReview.runOnce(q) | ||
return dbReview.runOnce(q) | ||
}).delay(5200).then(() => { | ||
dbReview.runOnce(q) | ||
return dbReview.runOnce(q) | ||
}).delay(3200).then(() => { | ||
@@ -285,7 +288,7 @@ jobDelay = 200 | ||
}).then(() => { | ||
jobs = q.createJob() | ||
testCancel = true | ||
// ---------- Processing with Cancel Test ---------- | ||
t.comment('queue-process: Processing with Cancel') | ||
testCancel = true | ||
jobs = q.createJob() | ||
return q.addJob(jobs) | ||
@@ -296,7 +299,30 @@ }).delay(1000).then(() => { | ||
t.equal(cancelledJob[0].status, enums.status.cancelled, 'Job is cancelled') | ||
}).then(() => { | ||
testCancel = false | ||
// ---------- Delayed Job Start Test ---------- | ||
t.comment('queue-process: Delayed Job Start') | ||
jobs = q.createJob() | ||
jobs.dateEnable = moment().add(2, 'seconds').toDate() | ||
return q.addJob(jobs) | ||
}).delay(500).then(() => { | ||
return queueProcess.restart(q) | ||
}).delay(500).then(() => { | ||
return q.getJob(jobs) | ||
}).then((delayedJobs) => { | ||
t.equal(delayedJobs[0].status, enums.status.added, 'Delayed job has status: added') | ||
}).delay(2000).then(() => { | ||
return queueProcess.restart(q) | ||
}).delay(1000).then(() => { | ||
return q.getJob(jobs) | ||
}).then((delayedJobs3) => { | ||
t.equal(delayedJobs3[0].status, enums.status.completed, 'Delayed job has status: completed') | ||
// ---------- Queue Summary ---------- | ||
t.comment('queue-process: Queue Summary') | ||
return q.summary() | ||
}).then((queueSummary) => { | ||
t.equal(queueSummary.completed, 31, 'Summary 31 jobs completed') | ||
t.equal(queueSummary.cancelled, 1, 'Summary 1 job cancelled') | ||
t.equal(queueSummary.terminated, 1, 'Summary 1 job terminated') | ||
t.equal(queueSummary.completed, summaryCompleted, `Summary ${summaryCompleted} jobs completed`) | ||
t.equal(queueSummary.cancelled, summaryCancelled, `Summary ${summaryCancelled} job cancelled`) | ||
t.equal(queueSummary.terminated, summaryTerminated, `Summary ${summaryTerminated} job terminated`) | ||
@@ -303,0 +329,0 @@ // ---------- Test Cleanup ---------- |
228958
5282
198
+ Addeduuid@^2.0.2
+ Addeduuid@2.0.3(transitive)
- Removednode-uuid@^1.4.7
- Removednode-uuid@1.4.8(transitive)
Updatedbluebird@^3.4.6
Updatedrethinkdbdash@^2.3.21