fixed and added a test for keepalive connection pool forced shutdown
This commit is contained in:
26
test/fixtures/keepalive.js
vendored
Normal file
26
test/fixtures/keepalive.js
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
var elasticsearch = require('../../src/elasticsearch');
|
||||
var _ = require('lodash');
|
||||
var es = elasticsearch.Client({
|
||||
host: 'localhost:5555',
|
||||
log: false
|
||||
});
|
||||
|
||||
es.search({
|
||||
index: '_all',
|
||||
type: '_all',
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}
|
||||
}, function (err, resp) {
|
||||
var conn = _.union(es.transport.connectionPool._conns.dead, es.transport.connectionPool._conns.alive).pop();
|
||||
es.close();
|
||||
var destroyedSockets = 0;
|
||||
function countDestroyed(sockets) {
|
||||
destroyedSockets += _.where(sockets, { destroyed: true}).length;
|
||||
}
|
||||
_.each(conn.agent.sockets, countDestroyed);
|
||||
_.each(conn.agent.freeSockets, countDestroyed);
|
||||
console.log(destroyedSockets);
|
||||
});
|
||||
Reference in New Issue
Block a user