mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
test: fix flaky timeout-delayed-body and headers tests
fix the flaky test-http-server-request-timeout-delayed-body and test-http-server-request-timeout-delayed-headers which sometimes fail on slow systems. PR-URL: https://github.com/nodejs/node/pull/38045 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
4f387c25cb
commit
d75543d8b5
5 changed files with 52 additions and 24 deletions
|
@ -8,9 +8,12 @@ const { connect } = require('net');
|
|||
// This test validates that the server returns 408
|
||||
// after server.requestTimeout if the client
|
||||
// pauses before start sending the request.
|
||||
|
||||
let sendDelayedRequestHeaders;
|
||||
const server = createServer(common.mustNotCall());
|
||||
|
||||
server.on('connection', common.mustCall(() => {
|
||||
assert.strictEqual(typeof sendDelayedRequestHeaders, 'function');
|
||||
sendDelayedRequestHeaders();
|
||||
}));
|
||||
// 0 seconds is the default
|
||||
assert.strictEqual(server.requestTimeout, 0);
|
||||
const requestTimeout = common.platformTimeout(1000);
|
||||
|
@ -39,10 +42,12 @@ server.listen(0, common.mustCall(() => {
|
|||
|
||||
client.resume();
|
||||
|
||||
setTimeout(() => {
|
||||
client.write('POST / HTTP/1.1\r\n');
|
||||
client.write('Content-Length: 20\r\n');
|
||||
client.write('Connection: close\r\n\r\n');
|
||||
client.write('12345678901234567890\r\n\r\n');
|
||||
}, common.platformTimeout(2000)).unref();
|
||||
sendDelayedRequestHeaders = common.mustCall(() => {
|
||||
setTimeout(() => {
|
||||
client.write('POST / HTTP/1.1\r\n');
|
||||
client.write('Content-Length: 20\r\n');
|
||||
client.write('Connection: close\r\n\r\n');
|
||||
client.write('12345678901234567890\r\n\r\n');
|
||||
}, common.platformTimeout(2000)).unref();
|
||||
});
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue