From 8fd49389f343031004fa22d487fd41f708c6fdc4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 5 Dec 2018 11:06:57 +0100 Subject: [PATCH] Added debug logs in test --- .travis.yml | 3 +-- package.json | 2 +- test/utils/buildCluster.js | 13 ++++++++++--- test/utils/buildServer.js | 5 +++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b4de52bce..743820f04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,13 +18,12 @@ before_install: - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz - tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz - ./elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -Enode.attr.testattr=test -Epath.repo=/tmp -Erepositories.url.allowed_urls='http://snapshot.*' &> /dev/null & - - ./scripts/wait-cluster.sh install: - npm install script: - - npm run lint && npm run test:unit && npm run test:integration + - npm run ci notifications: email: diff --git a/package.json b/package.json index 067af3ba8..49fff7e44 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ ], "scripts": { "test": "npm run lint && npm run test:unit && npm run test:types", - "test:unit": "tap test/unit/*.test.js -J -T", + "test:unit": "tap test/unit/*.test.js -T", "test:integration": "tap test/integration/index.js -T --harmony", "test:types": "tsc --project ./test/types/tsconfig.json", "lint": "standard", diff --git a/test/utils/buildCluster.js b/test/utils/buildCluster.js index d9c071655..79b0658ed 100644 --- a/test/utils/buildCluster.js +++ b/test/utils/buildCluster.js @@ -1,9 +1,13 @@ 'use strict' +const debug = require('debug')('elasticsearch-test') const workq = require('workq') const buildServer = require('./buildServer') +var id = 0 function buildCluster (opts, callback) { + const clusterId = id++ + debug(`Booting cluster '${clusterId}'`) if (typeof opts === 'function') { callback = opts opts = {} @@ -39,23 +43,25 @@ function buildCluster (opts, callback) { }, roles: ['master', 'data', 'ingest'] } + debug(`Booted cluster node '${opts.id}' on port ${port} (cluster id: '${clusterId}')`) done() }) } function shutdown () { - Object.keys(nodes).forEach(id => { - nodes[id].server.stop() - }) + debug(`Shutting down cluster '${clusterId}'`) + Object.keys(nodes).forEach(kill) } function kill (id) { + debug(`Shutting down cluster node '${id}' (cluster id: '${clusterId}')`) nodes[id].server.stop() delete nodes[id] delete sniffResult.nodes[id] } function spawn (id, callback) { + debug(`Spawning cluster node '${id}' (cluster id: '${clusterId}')`) q.add(bootNode, { id }) q.add((q, done) => { callback() @@ -71,6 +77,7 @@ function buildCluster (opts, callback) { } q.drain(done => { + debug(`Cluster '${clusterId}' booted with ${opts.numberOfNodes} nodes`) callback(cluster) done() }) diff --git a/test/utils/buildServer.js b/test/utils/buildServer.js index 5dde978bf..235195594 100644 --- a/test/utils/buildServer.js +++ b/test/utils/buildServer.js @@ -1,5 +1,6 @@ 'use strict' +const debug = require('debug')('elasticsearch-test') const stoppable = require('stoppable') // allow self signed certificates for testing purposes @@ -15,7 +16,10 @@ const secureOpts = { cert: readFileSync(join(__dirname, '..', 'fixtures', 'https.cert'), 'utf8') } +var id = 0 function buildServer (handler, opts, cb) { + const serverId = id++ + debug(`Booting server '${serverId}'`) if (cb == null) { cb = opts opts = {} @@ -32,6 +36,7 @@ function buildServer (handler, opts, cb) { }) server.listen(0, () => { const port = server.address().port + debug(`Server '${serverId}' booted on port ${port}`) cb(Object.assign({}, secureOpts, { port }), server) }) }