when there are timeouts left behind we should spit them out
This commit is contained in:
26
test/fixtures/keepalive.js
vendored
26
test/fixtures/keepalive.js
vendored
@ -1,33 +1,33 @@
|
||||
var clock = require('sinon').useFakeTimers();
|
||||
var elasticsearch = require('../../src/elasticsearch');
|
||||
var Client = require('../../src/elasticsearch').Client;
|
||||
var _ = require('lodash-node');
|
||||
var times = require('async').times;
|
||||
|
||||
var app = require('express')();
|
||||
app.post('/_search', function (req, res) {
|
||||
res.json(200, { hits: { hits: [] } });
|
||||
res.json(200, { hits: { hits: [] } });
|
||||
});
|
||||
|
||||
var server = require('http').createServer(app);
|
||||
server.listen(function () {
|
||||
var es = elasticsearch.Client({
|
||||
var es = new Client({
|
||||
host: 'http://127.0.0.1:' + server.address().port,
|
||||
log: false
|
||||
});
|
||||
|
||||
var matchAll = {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
};
|
||||
|
||||
times(1000, function (i, done) {
|
||||
es.search({
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}
|
||||
body: matchAll
|
||||
}, _.partial(done, null)); // ignore errors
|
||||
clock.tick(10);
|
||||
}, function () {
|
||||
|
||||
server.close();
|
||||
|
||||
var sockets = _(es.transport.connectionPool._conns.dead)
|
||||
.concat(es.transport.connectionPool._conns.alive)
|
||||
.transform(function (sockets, conn) {
|
||||
@ -37,14 +37,16 @@ server.listen(function () {
|
||||
.flatten()
|
||||
.value();
|
||||
|
||||
server.close();
|
||||
es.close();
|
||||
clock.restore();
|
||||
|
||||
var out = {
|
||||
socketCount: sockets.length,
|
||||
remaining: _.where(sockets, { destroyed: true }).length - sockets.length,
|
||||
timeouts: _.size(clock.timeouts)
|
||||
timeouts: _.size(clock.timeouts) && clock.timeouts
|
||||
};
|
||||
|
||||
clock.restore();
|
||||
process.connected ? process.send(out) : console.log(out);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user