fixed and added a test for keepalive connection pool forced shutdown

This commit is contained in:
Spencer Alger
2014-02-06 22:30:29 -07:00
parent 7bb19ac357
commit 327f191056
6 changed files with 112 additions and 12 deletions

26
test/fixtures/keepalive.js vendored Normal file
View 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);
});