[MediaWiki-commits] [Gerrit] mediawiki...chromium-render[master]: Make chromium testing easier
Bmansurov has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/392051 ) Change subject: Make chromium testing easier .. Make chromium testing easier Changes: - make logging more verbose - add a `start:formatted` command that outputs human readable logs Bug: T180601 Change-Id: I772458d797127a6bdd2095f737e9fcc41e23f850 --- M lib/queue.js M package.json 2 files changed, 20 insertions(+), 4 deletions(-) Approvals: Bmansurov: Verified; Looks good to me, approved diff --git a/lib/queue.js b/lib/queue.js index 8b25f9c..22e7022 100644 --- a/lib/queue.js +++ b/lib/queue.js @@ -44,13 +44,20 @@ } /** + * Return number of waiting/in progress jobs + * @return {Number} + */ +_countJobsInQueue() { +const queue = this._queueObject; +return queue.length() + queue.running(); +} +/** * Whether the queue full * @return {boolean} whether the number of running and waiting tasks * is equal to a predefined maximum task count */ _isQueueFull() { -const queue = this._queueObject; -return queue.length() + queue.running() === this._options.maxTaskCount; +return this._countJobsInQueue() === this._options.maxTaskCount; } /** @@ -114,6 +121,10 @@ } // make sure to cancel the task if it doesn't start within a timeframe this._setCancelTaskTimeout(data, callback); +const queueSize = this._countJobsInQueue(); +this._logger.log( +'info/queue', `Job ${data._id} added to the queue. Jobs waiting: ${queueSize}` +); this._queueObject.push(data, callback); } @@ -128,16 +139,19 @@ */ _worker(data, callback) { this._clearCancelTaskTimeout(data); - +this._logger.log('info/queue', `Started rendering ${data._id}`); renderer .articleToPdf(data.uri, data.format, this._puppeteerFlags, this._pdfOptions) .then((pdf) => { +this._logger.log( +'info/queue', `Job ${data._id} rendered successfully` +); callback(null, pdf); }) .catch((error) => { this._logger.log('error/render', { -msg: `Cannot convert page ${data.uri} to PDF.`, +msg: `Cannot convert page ${data.uri} to PDF. Error: ${error.toString()}`, error }); callback(callbackErrors.renderFailed, null); diff --git a/package.json b/package.json index 863fdd0..8da44e9 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "./app.js", "scripts": { "start": "service-runner", +"start:formatted": "service-runner | while read line; do echo \"$line\" | json -a time, msg; done", "test": "PREQ_CONNECT_TIMEOUT=15 mocha && nsp check", "docker-start": "service-runner docker-start", "docker-test": "service-runner docker-test", @@ -50,6 +51,7 @@ "mocha": "^3.2.0", "mocha-jshint": "^2.3.1", "mocha-lcov-reporter": "^1.3.0", +"json" :"9.0.6", "nsp": "^2.6.3", "mocha-eslint": "^3.0.1", "eslint": "^3.12.0", -- To view, visit https://gerrit.wikimedia.org/r/392051 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I772458d797127a6bdd2095f737e9fcc41e23f850 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/chromium-render Gerrit-Branch: master Gerrit-Owner: PmiazgaGerrit-Reviewer: Bmansurov Gerrit-Reviewer: Mobrovac ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...chromium-render[master]: Make chromium testing easier
Pmiazga has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/392051 ) Change subject: Make chromium testing easier .. Make chromium testing easier Changes: - make logging more verbose - add a `start:formatted` command that outputs human readable logs Bug: T180601 Change-Id: I772458d797127a6bdd2095f737e9fcc41e23f850 --- M lib/queue.js M package.json 2 files changed, 20 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/chromium-render refs/changes/51/392051/1 diff --git a/lib/queue.js b/lib/queue.js index 8b25f9c..22e7022 100644 --- a/lib/queue.js +++ b/lib/queue.js @@ -44,13 +44,20 @@ } /** + * Return number of waiting/in progress jobs + * @return {Number} + */ +_countJobsInQueue() { +const queue = this._queueObject; +return queue.length() + queue.running(); +} +/** * Whether the queue full * @return {boolean} whether the number of running and waiting tasks * is equal to a predefined maximum task count */ _isQueueFull() { -const queue = this._queueObject; -return queue.length() + queue.running() === this._options.maxTaskCount; +return this._countJobsInQueue() === this._options.maxTaskCount; } /** @@ -114,6 +121,10 @@ } // make sure to cancel the task if it doesn't start within a timeframe this._setCancelTaskTimeout(data, callback); +const queueSize = this._countJobsInQueue(); +this._logger.log( +'info/queue', `Job ${data._id} added to the queue. Jobs waiting: ${queueSize}` +); this._queueObject.push(data, callback); } @@ -128,16 +139,19 @@ */ _worker(data, callback) { this._clearCancelTaskTimeout(data); - +this._logger.log('info/queue', `Started rendering ${data._id}`); renderer .articleToPdf(data.uri, data.format, this._puppeteerFlags, this._pdfOptions) .then((pdf) => { +this._logger.log( +'info/queue', `Job ${data._id} rendered successfully` +); callback(null, pdf); }) .catch((error) => { this._logger.log('error/render', { -msg: `Cannot convert page ${data.uri} to PDF.`, +msg: `Cannot convert page ${data.uri} to PDF. Error: ${error.toString()}`, error }); callback(callbackErrors.renderFailed, null); diff --git a/package.json b/package.json index 863fdd0..8da44e9 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "./app.js", "scripts": { "start": "service-runner", +"start:formatted": "service-runner | while read line; do echo \"$line\" | json -a time, msg; done", "test": "PREQ_CONNECT_TIMEOUT=15 mocha && nsp check", "docker-start": "service-runner docker-start", "docker-test": "service-runner docker-test", @@ -50,6 +51,7 @@ "mocha": "^3.2.0", "mocha-jshint": "^2.3.1", "mocha-lcov-reporter": "^1.3.0", +"json" :"9.0.6", "nsp": "^2.6.3", "mocha-eslint": "^3.0.1", "eslint": "^3.12.0", -- To view, visit https://gerrit.wikimedia.org/r/392051 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I772458d797127a6bdd2095f737e9fcc41e23f850 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/chromium-render Gerrit-Branch: master Gerrit-Owner: Pmiazga___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits