From ee17336d640f0153095baf0b2031103043297495 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Mon, 15 Jun 2015 16:24:47 +0200 Subject: [PATCH 1/6] Remove unused import. --- src/api/token.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/api/token.js b/src/api/token.js index 516d1788b..40df4be70 100644 --- a/src/api/token.js +++ b/src/api/token.js @@ -1,7 +1,3 @@ -import {Unauthorized} from '../api-errors' - -// =================================================================== - // TODO: Prevent token connections from creating tokens. // TODO: Token permission. export async function create () { From 8b9389b468a554c11216d6f03672705d4f1449ee Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Mon, 15 Jun 2015 16:27:02 +0200 Subject: [PATCH 2/6] Fix tests execution on Windows. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b1a7be35..985f1f0d7 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "lint": "standard", "prepublish": "npm run build", "start": "node bin/xo-server", - "test": "npm run lint && dependency-check ./package.json && mocha --opts .mocha.opts 'dist/**/*.spec.js'" + "test": "npm run lint && dependency-check ./package.json && mocha --opts .mocha.opts \"dist/**/*.spec.js\"" }, "standard": { "ignore": [ From 49a49e2a2c6f4172d207214363ce05bdb84b8622 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Mon, 15 Jun 2015 16:41:11 +0200 Subject: [PATCH 3/6] Use must instead of chai. --- package.json | 2 +- src/decorators.spec.js | 2 +- src/utils.spec.js | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 985f1f0d7..067d8d826 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,6 @@ "devDependencies": { "babel-eslint": "^3.1.9", "babel-plugin-closure-elimination": "0.0.1", - "chai": "~2.1.2", "dependency-check": "^2.4.0", "gulp": "git://github.com/gulpjs/gulp#4.0", "gulp-babel": "^5", @@ -96,6 +95,7 @@ "gulp-sourcemaps": "^1.5.1", "gulp-watch": "^4.2.2", "mocha": "^2.2.1", + "must": "^0.12.0", "node-inspector": "^0.10.1", "sinon": "^1.14.1", "standard": "^4.0.0" diff --git a/src/decorators.spec.js b/src/decorators.spec.js index 376477045..ea555ea0b 100644 --- a/src/decorators.spec.js +++ b/src/decorators.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import {expect} from 'chai' +import expect from 'must' // =================================================================== diff --git a/src/utils.spec.js b/src/utils.spec.js index fb148c7e2..38142afff 100644 --- a/src/utils.spec.js +++ b/src/utils.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import {expect} from 'chai' +import expect from 'must' // =================================================================== @@ -12,6 +12,12 @@ import { // =================================================================== describe('ensureArray', function () { + it('wrap the value in an array', function () { + const value = 'foo' + + expect(ensureArray(value)).to.eql([value]) + }) + it('returns an empty array for undefined', function () { expect(ensureArray(undefined)).to.eql([]) }) @@ -21,12 +27,6 @@ describe('ensureArray', function () { expect(ensureArray(array)).to.equal(array) }) - - it('wrap the value in an object', function () { - const value = {} - - expect(ensureArray(value)).to.includes(value) - }) }) // ------------------------------------------------------------------- From 127f4446ae075e7bea0066f03f06303bb383e7be Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 18 Jun 2015 10:48:40 +0200 Subject: [PATCH 4/6] Log SIGINT & SIGTERM. --- src/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index ad577197f..8d23bfe9f 100644 --- a/src/index.js +++ b/src/index.js @@ -447,10 +447,18 @@ export default async function main (args) { info('Default user created:', email, ' with password', password) } - // Handle gracefully shutdown. - const closeWebServer = () => { webServer.close() } - process.on('SIGINT', closeWebServer) - process.on('SIGTERM', closeWebServer) + // Gracefully shutdown on signals. + // + // TODO: implements a timeout? (or maybe it is the services launcher + // responsability?) + process.on('SIGINT', () => { + debug('SIGINT caught, closing web server…') + webServer.close() + }) + process.on('SIGTERM', () => { + debug('SIGTERM caught, closing web server…') + webServer.close() + }) return eventToPromise(webServer, 'close') } From 5c414fc7b4fe32a7f10dc2feabc78fac090c3564 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 18 Jun 2015 11:05:44 +0200 Subject: [PATCH 5/6] Test on both io.js v1 & v2. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e667b9209..d38f7e60a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: - - 'iojs' + - 'iojs-v2' + - 'iojs-v1' - '0.12' - '0.10' From 6d87a1a604e6405d66da945190a8c7c7d9271fc8 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 18 Jun 2015 13:41:34 +0200 Subject: [PATCH 6/6] Update xen-api to 0.5.6. --- package.json | 2 +- src/xapi.js | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 067d8d826..89ae17e83 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "then-redis": "~1.3.0", "trace": "^1.2.0", "ws": "~0.7.1", - "xen-api": "^0.5.4", + "xen-api": "^0.5.6", "xml2js": "~0.4.6", "xo-collection": "^0.3.2" }, diff --git a/src/xapi.js b/src/xapi.js index 123b2e4b3..01203c471 100644 --- a/src/xapi.js +++ b/src/xapi.js @@ -7,7 +7,10 @@ import map from 'lodash.map' import unzip from 'julien-f-unzip' import {PassThrough} from 'stream' import {promisify} from 'bluebird' -import {Xapi as XapiBase} from 'xen-api' +import { + wrapError as wrapXapiError, + Xapi as XapiBase +} from 'xen-api' import {debounce} from './decorators' import {ensureArray, noop, parseXml, pFinally} from './utils' @@ -19,13 +22,6 @@ const debug = createDebug('xo:xapi') const gotPromise = promisify(got) -const wrapError = error => { - const e = new Error(error[0]) - e.code = error[0] - e.params = error.slice(1) - return e -} - // =================================================================== const typeToNamespace = Object.create(null) @@ -107,7 +103,7 @@ export default class Xapi extends XapiBase { if (status === 'success') { taskWatchers[ref].resolve(object.result) } else if (status === 'failure') { - taskWatchers[ref].reject(wrapError(object.error_info)) + taskWatchers[ref].reject(wrapXapiError(object.error_info)) } else { return }