diff --git a/test/parallel/test-http-agent-keepalive.js b/test/parallel/test-http-agent-keepalive.js index a1f902fab091e1..427f242999c060 100644 --- a/test/parallel/test-http-agent-keepalive.js +++ b/test/parallel/test-http-agent-keepalive.js @@ -59,6 +59,7 @@ function checkDataAndSockets(body) { assert.strictEqual(body.toString(), 'hello world'); assert.strictEqual(agent.sockets[name].length, 1); assert.strictEqual(agent.freeSockets[name], undefined); + assert.strictEqual(agent.totalSocketCount, 1); } function second() { @@ -73,6 +74,7 @@ function second() { process.nextTick(common.mustCall(() => { assert.strictEqual(agent.sockets[name], undefined); assert.strictEqual(agent.freeSockets[name].length, 1); + assert.strictEqual(agent.totalSocketCount, 0); remoteClose(); })); })); @@ -91,6 +93,7 @@ function remoteClose() { process.nextTick(common.mustCall(() => { assert.strictEqual(agent.sockets[name], undefined); assert.strictEqual(agent.freeSockets[name].length, 1); + assert.strictEqual(agent.totalSocketCount, 0); // Waiting remote server close the socket setTimeout(common.mustCall(() => { assert.strictEqual(agent.sockets[name], undefined); @@ -110,10 +113,12 @@ function remoteError() { assert.strictEqual(err.message, 'socket hang up'); assert.strictEqual(agent.sockets[name].length, 1); assert.strictEqual(agent.freeSockets[name], undefined); + assert.strictEqual(agent.totalSocketCount, 0); // Wait socket 'close' event emit setTimeout(common.mustCall(() => { assert.strictEqual(agent.sockets[name], undefined); assert.strictEqual(agent.freeSockets[name], undefined); + assert.strictEqual(agent.totalSocketCount, -1); server.close(); }), common.platformTimeout(1)); })); @@ -132,6 +137,7 @@ server.listen(0, common.mustCall(() => { process.nextTick(common.mustCall(() => { assert.strictEqual(agent.sockets[name], undefined); assert.strictEqual(agent.freeSockets[name].length, 1); + assert.strictEqual(agent.totalSocketCount, 0); second(); })); }));