Added debug logs in test

This commit is contained in:
delvedor
2018-12-05 11:06:57 +01:00
parent 4b2df7504e
commit 8fd49389f3
4 changed files with 17 additions and 6 deletions

View File

@ -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()
})