Browse Source

test: backoff client connection rates

We were being very aggressive in our connection creations, resulting
in the pipeline flood detection to drop us. Relax how fast we're
creating these connections so the gc can run all its tests.
v0.11.12-release
Timothy J Fontaine 11 years ago
parent
commit
af1418325b
  1. 10
      test/gc/test-http-client-connaborted.js
  2. 14
      test/gc/test-http-client-onerror.js
  3. 14
      test/gc/test-http-client-timeout.js
  4. 20
      test/gc/test-http-client.js
  5. 32
      test/gc/test-net-timeout.js

10
test/gc/test-http-client-connaborted.js

@ -22,7 +22,9 @@ var server = http.createServer(serverHandler);
server.listen(PORT, getall);
function getall() {
for (var i = 0; i < todo; i++) {
if (count >= todo)
return;
(function(){
function cb(res) {
done+=1;
@ -38,8 +40,12 @@ function getall() {
count++;
weak(req, afterGC);
})()
setImmediate(getall);
}
}
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
countGC ++;

14
test/gc/test-http-client-onerror.js

@ -2,6 +2,7 @@
// but with an on('error') handler that does nothing.
function serverHandler(req, res) {
req.resume();
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}
@ -23,9 +24,12 @@ var server = http.createServer(serverHandler);
server.listen(PORT, getall);
function getall() {
for (var i = 0; i < todo; i++) {
if (count >= todo)
return;
(function(){
function cb(res) {
res.resume();
done+=1;
statusLater();
}
@ -42,8 +46,12 @@ function getall() {
count++;
weak(req, afterGC);
})()
setImmediate(getall);
}
}
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
countGC ++;
@ -62,7 +70,7 @@ function status() {
console.log('Collected: %d/%d', countGC, count);
if (done === todo) {
console.log('All should be collected now.');
assert(count === countGC);
assert.strictEqual(count, countGC);
process.exit(0);
}
}

14
test/gc/test-http-client-timeout.js

@ -3,6 +3,7 @@
function serverHandler(req, res) {
setTimeout(function () {
req.resume();
res.writeHead(200)
res.end('hello\n');
}, 100);
@ -25,9 +26,12 @@ var server = http.createServer(serverHandler);
server.listen(PORT, getall);
function getall() {
for (var i = 0; i < todo; i++) {
if (count >= todo)
return;
(function(){
function cb() {
function cb(res) {
res.resume();
done+=1;
statusLater();
}
@ -45,8 +49,12 @@ function getall() {
count++;
weak(req, afterGC);
})()
setImmediate(getall);
}
}
for(var i = 0; i < 10; i++)
getall();
function afterGC(){
countGC ++;

20
test/gc/test-http-client.js

@ -23,12 +23,15 @@ server.listen(PORT, getall);
function getall() {
for (var i = 0; i < todo; i++) {
if (count >= todo)
return;
(function(){
function cb(res) {
res.resume();
console.error('in cb')
done+=1;
res.on('end', statusLater);
res.on('end', gc);
}
var req = http.get({
@ -40,19 +43,18 @@ function getall() {
count++;
weak(req, afterGC);
})()
}
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
countGC ++;
}
var timer;
function statusLater() {
gc();
if (timer) clearTimeout(timer);
timer = setTimeout(status, 1);
}
setInterval(status, 1000).unref();
function status() {
gc();

32
test/gc/test-net-timeout.js

@ -3,7 +3,15 @@
function serverHandler(sock) {
sock.setTimeout(120000);
setTimeout(function () {
sock.resume();
var timer;
sock.on('close', function() {
clearTimeout(timer);
});
sock.on('error', function(err) {
assert.strictEqual(err.code, 'ECONNRESET');
});
timer = setTimeout(function () {
sock.end('hello\n');
}, 100);
}
@ -24,32 +32,34 @@ var server = net.createServer(serverHandler);
server.listen(PORT, getall);
function getall() {
for (var i = 0; i < todo; i++) {
if (count >= todo)
return;
(function(){
var req = net.connect(PORT, '127.0.0.1');
req.resume();
req.setTimeout(10, function() {
console.log('timeout (expected)')
//console.log('timeout (expected)')
req.destroy();
done++;
statusLater();
gc();
});
count++;
weak(req, afterGC);
})();
setImmediate(getall);
}
}
for (var i = 0; i < 10; i++)
getall();
function afterGC(){
countGC ++;
}
var timer;
function statusLater() {
gc();
if (timer) clearTimeout(timer);
timer = setTimeout(status, 1);
}
setInterval(status, 100).unref();
function status() {
gc();

Loading…
Cancel
Save