Added "extends" key to the jshint config files, so there is less repetition.
Mocha now runs from grunt, just run "grunt" Copied es-php's README.md, will modify later More logging around sending a request, including stack traces for debug messages Connections now manage their own state, and emit a "status changed" event which the connection pool listens for Fixed the custom errors Stream loggers will dump their buffered output to stderr when the process exits so that log messages will be sort of saved, File logger overrides this and writes to the file syncronously Added _.handler(), _.scheduled(), and _.makeBoundMethods() to the utils
This commit is contained in:
@ -0,0 +1,61 @@
|
||||
|
||||
var EsServer = require('../../mocks/es_server');
|
||||
var HttpConnection = require('../../../src/lib/connections/http');
|
||||
var errors = require('../../../src/lib/errors');
|
||||
|
||||
describe('overall timeout for the network connections', function () {
|
||||
|
||||
var server;
|
||||
var connection;
|
||||
|
||||
before(function (done) {
|
||||
|
||||
server = new EsServer();
|
||||
|
||||
server.routes.get['/timeout'] = function (req, res) {
|
||||
// wait for 10 seconds before responding, or the value in the timeout param
|
||||
var timeout = parseInt(req.parsedUrl.query.timeout, 10);
|
||||
if (isNaN(timeout)) {
|
||||
timeout = 10000;
|
||||
}
|
||||
|
||||
res.writeHead(200);
|
||||
|
||||
res.on('close', function() {
|
||||
clearInterval(dataInterval);
|
||||
clearTimeout(finTimeout);
|
||||
});
|
||||
|
||||
var dataInterval = setInterval(function () {
|
||||
res.write('.');
|
||||
}, 100);
|
||||
|
||||
var finTimeout = setTimeout(function () {
|
||||
clearInterval(dataInterval);
|
||||
res.end('good bye');
|
||||
}, timeout);
|
||||
};
|
||||
|
||||
server.on('online', function (port) {
|
||||
connection = new HttpConnection({
|
||||
hostname: 'localhost',
|
||||
port: port
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should bail quickly', function (done) {
|
||||
this.timeout(1000);
|
||||
connection.request({
|
||||
path: '/timeout?timeout=1000',
|
||||
timeout: 100
|
||||
}, function (err, resp, status) {
|
||||
err.should.be.an.instanceof(errors.RequestTimeout);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user