Added debug logs in test
This commit is contained in:
@ -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()
|
||||
})
|
||||
|
||||
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user