updated the keepalive test so that it uses IPC instead of output parsing.

This commit is contained in:
Spencer Alger
2014-03-27 10:41:01 -07:00
parent 4ab22a1a61
commit 6ca5453195
2 changed files with 37 additions and 36 deletions

View File

@ -1,38 +1,41 @@
var clock = require('sinon').useFakeTimers();
var elasticsearch = require('../../src/elasticsearch');
var _ = require('lodash-node');
var times = require('async').times;
var es = elasticsearch.Client({
host: 'localhost:5555',
host: 'no-a-real-host-for-sure.bike:5555',
log: false
});
es.search({
index: '_all',
type: '_all',
body: {
query: {
match_all: {}
times(100, function (i, done) {
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();
}, _.partial(done, null)); // ignore errors
clock.tick(10);
}, function () {
var sockets = _(es.transport.connectionPool._conns.dead)
.concat(es.transport.connectionPool._conns.alive)
.transform(function (sockets, conn) {
[].push.apply(sockets, _.values(conn.agent.sockets));
[].push.apply(sockets, _.values(conn.agent.freeSockets));
}, [])
.flatten()
.value();
es.close();
if (_.size(clock.timeouts)) {
console.log('Timeouts were left behind');
console.log(clock);
}
clock.restore();
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);
});
clock.tick(10);
var out = {
socketCount: sockets.length,
remaining: _.where(sockets, { destroyed: true }).length - sockets.length,
timeouts: _.size(clock.timeouts)
};
process.connected ? process.send(out) : console.log(out);
});