Skip to content

Commit

Permalink
test: fix flaky HTTP server tests
Browse files Browse the repository at this point in the history
Refs: #41263

PR-URL: #42846
Fixes: #42741
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
  • Loading branch information
tniessen authored Apr 24, 2022
1 parent 7729e32 commit 0288844
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
9 changes: 3 additions & 6 deletions test/parallel/test-http-server-headers-timeout-keepalive.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
client.resume();
client.write('GET / HTTP/1.1\r\n');

firstDelay = common.platformTimeout(firstDelay);
secondDelay = common.platformTimeout(secondDelay);

setTimeout(() => {
client.write('Connection: ');
}, firstDelay).unref();
Expand All @@ -27,12 +24,12 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
}, firstDelay + secondDelay).unref();
}

const headersTimeout = common.platformTimeout(1000);
const headersTimeout = common.platformTimeout(2000);
const server = createServer({
headersTimeout,
requestTimeout: 0,
keepAliveTimeout: 0,
connectionsCheckingInterval: common.platformTimeout(250),
connectionsCheckingInterval: headersTimeout / 4,
}, common.mustCallAtLeast((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end();
Expand Down Expand Up @@ -60,7 +57,7 @@ server.listen(0, common.mustCall(() => {
'HTTP/1.1 200 OK'
);

const defer = common.platformTimeout(headersTimeout * 1.5);
const defer = headersTimeout * 1.5;

// Wait some time to make sure headersTimeout
// does not interfere with keep alive
Expand Down
9 changes: 3 additions & 6 deletions test/parallel/test-http-server-request-timeout-keepalive.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
client.resume();
client.write('GET / HTTP/1.1\r\n');

firstDelay = common.platformTimeout(firstDelay);
secondDelay = common.platformTimeout(secondDelay);

setTimeout(() => {
client.write('Connection: ');
}, firstDelay).unref();
Expand All @@ -27,12 +24,12 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
}, firstDelay + secondDelay).unref();
}

const requestTimeout = common.platformTimeout(1000);
const requestTimeout = common.platformTimeout(2000);
const server = createServer({
headersTimeout: 0,
requestTimeout,
keepAliveTimeout: 0,
connectionsCheckingInterval: common.platformTimeout(250),
connectionsCheckingInterval: requestTimeout / 4
}, common.mustCallAtLeast((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end();
Expand All @@ -58,7 +55,7 @@ server.listen(0, common.mustCall(() => {
'HTTP/1.1 200 OK'
);

const defer = common.platformTimeout(requestTimeout * 1.5);
const defer = requestTimeout * 1.5;

// Wait some time to make sure requestTimeout
// does not interfere with keep alive
Expand Down

0 comments on commit 0288844

Please sign in to comment.