attempting to diagnos random issues with the client.close() test
This commit is contained in:
@ -57,17 +57,21 @@ _.inherits(HttpConnector, ConnectionAbstract);
|
||||
|
||||
HttpConnector.prototype.onStatusSet = _.handler(function (status) {
|
||||
if (status === 'closed') {
|
||||
this.agent.minSockets = this.agent.maxSockets = 0;
|
||||
var agent = this.agent;
|
||||
agent.minSockets = agent.maxSockets = 0;
|
||||
agent.requests = {};
|
||||
|
||||
_.each(this.agent.sockets, function (sockets) {
|
||||
_.each(agent.sockets, function (sockets, group) {
|
||||
_.each(sockets, function (s) {
|
||||
s.destroy();
|
||||
s && agent.removeSocket(s, group);
|
||||
s && s.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
_.each(this.agent.freeSockets, function (sockets) {
|
||||
_.each(agent.freeSockets, function (sockets, group) {
|
||||
_.each(sockets, function (s) {
|
||||
s.destroy();
|
||||
s && agent.removeSocket(s, group);
|
||||
s && s.destroy();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
10
test/fixtures/keepalive.js
vendored
10
test/fixtures/keepalive.js
vendored
@ -1,5 +1,7 @@
|
||||
var elasticsearch = require('../../src/elasticsearch');
|
||||
var _ = require('lodash');
|
||||
var clock = require('sinon').useFakeTimers();
|
||||
|
||||
var es = elasticsearch.Client({
|
||||
host: 'localhost:5555',
|
||||
log: false
|
||||
@ -16,6 +18,12 @@ es.search({
|
||||
}, function (err, resp) {
|
||||
var conn = _.union(es.transport.connectionPool._conns.dead, es.transport.connectionPool._conns.alive).pop();
|
||||
es.close();
|
||||
|
||||
if (_.size(clock.timeouts)) {
|
||||
console.log('Timeouts were left behind');
|
||||
console.log(clock);
|
||||
}
|
||||
|
||||
var destroyedSockets = 0;
|
||||
function countDestroyed(sockets) {
|
||||
destroyedSockets += _.where(sockets, { destroyed: true}).length;
|
||||
@ -24,3 +32,5 @@ es.search({
|
||||
_.each(conn.agent.freeSockets, countDestroyed);
|
||||
console.log(destroyedSockets);
|
||||
});
|
||||
|
||||
clock.tick(1);
|
||||
@ -371,6 +371,7 @@ describe('Http Connector', function () {
|
||||
|
||||
describe('Connection cleanup', function () {
|
||||
it('destroys any connections created', function (done) {
|
||||
this.timeout(4000);
|
||||
var cp = require('child_process');
|
||||
var path = require('path');
|
||||
var es = require('event-stream');
|
||||
|
||||
Reference in New Issue
Block a user