test: improve debugging information for http2 test

In test-http2-session-timeout, provide the number of requests that
occurred when the test fails.

PR-URL: https://github.com/nodejs/node/pull/23058
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
Rich Trott authored and Michaël Zasso committed 2018-10-03 07:59:08 +02:00
1 parent f486186e25
commit 48c1c428f9
1 file changed
+8 -1
@@ -3,10 +3,15 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const http2 = require('http2');
const serverTimeout = common.platformTimeout(200);
const mustNotCall = common.mustNotCall();
let requests = 0;
const mustNotCall = () => {
assert.fail(`Timeout after ${requests} request(s)`);
};
const server = http2.createServer();
server.timeout = serverTimeout;
@@ -32,6 +37,8 @@ server.listen(0, common.mustCall(() => {
request.resume();
request.end();
requests += 1;
request.on('end', () => {
const diff = process.hrtime(startTime);
const milliseconds = (diff[0] * 1e3 + diff[1] / 1e6);