Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: simplify the test cases in http timeouts mix #43470

Closed
wants to merge 2 commits into from

Conversation

MrJithil
Copy link
Member

@MrJithil MrJithil commented Jun 18, 2022

Simplified the test cases which causing flaky #43465

No test cases removed.

Inspired from the video of @mhdawson - https://www.youtube.com/watch?v=5WtkRoGtbx4

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jun 18, 2022
@F3n67u F3n67u requested a review from ShogunPanda June 18, 2022 13:39
@F3n67u F3n67u added the flaky-test Issues and PRs related to the tests with unstable failures on the CI. label Jun 18, 2022
@F3n67u
Copy link
Member

F3n67u commented Jun 18, 2022

Nit: could you change the pr title to test: simplify the test cases in http timeouts mix or some more specific title, please?

@MrJithil MrJithil changed the title Fix 43465 test: simplify the test cases in http timeouts mix Jun 18, 2022
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to be able to catch never settling promises.

test/parallel/test-http-server-request-timeouts-mixed.js Outdated Show resolved Hide resolved
test/parallel/test-http-server-request-timeouts-mixed.js Outdated Show resolved Hide resolved

// Finish the first request now and wait more than the request timeout value
request1.client.write(requestBodyPart2 + requestBodyPart3);
await delay(threadSleepDelay);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding this changes the original test. request3 and request4 are created after the requestTimeout expired.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request3 and request4 are created at request1 creation time + threadSleepDelay, where threadSleepDelay = requestTimeout + headersTimeout.

It's not like this in the original test. All request are created in a requestTimeout interval in the original one. There are 4 concurrent requests. Now there are 2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But, basically we are testing 5 requests header timeout. In the previous pattern, we are doing it using some setTimeout functions and it was causing the flaky.
So, rewritten that to this way.

Copy link
Member

@lpinca lpinca Jun 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these tests already has a standalone version. This one was made to test concurrent requests. If we have to change it like this, it is better to remove it completely as per https://github.com/nodejs/node/pull/42893/files#r861466882.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Bu, as per the conversation, PR owner telling that he added this case to make concurrent requests and testing them together.

Previously, 5 concurrent requests are creating. Now, we are creating 2 concurrent requests at a time. Again, we are creating 3 concurrent requests.

This splitting is to avoid flakiness.

Instead of removing, I prefer to have some test for concurrency at least. I appreciate that you already forecasted the flakiness in #42893 . Good work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but I'm -1 to change the test like this. Again, this changes the original intentions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, this test should have 4 concurrent request to properly test the possible combinations.
We can revisit the timeout schedule (and eventually use async/await for readable, but please do not change the order of creation.

@F3n67u
Copy link
Member

F3n67u commented Jun 27, 2022

This test is top 1 flaky test in all last week. If we could not make progress to fix this flaky test, so you mind mark this test as flaky? https://github.com/nodejs/reliability/issues

@ShogunPanda
Copy link
Contributor

Yes, that's on my TODO list. I'll do it very soon!

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there's no need to use util.promisify, Node.js ships a promisified version already.

@@ -16,10 +17,13 @@ const responseTimeout = 'HTTP/1.1 408 Request Timeout\r\n';

const headersTimeout = common.platformTimeout(2000);
const connectionsCheckingInterval = headersTimeout / 4;
const requestTimeout = headersTimeout * 2;
const threadSleepDelay = requestTimeout + headersTimeout;
const delay = promisify(setTimeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const delay = promisify(setTimeout);

@@ -4,6 +4,7 @@ const common = require('../common');
const assert = require('assert');
const { createServer } = require('http');
const { connect } = require('net');
const { promisify } = require('util');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { promisify } = require('util');
const { setTimeout: delay } = require('timers/promises');

test/parallel/test-http-server-request-timeouts-mixed.js Outdated Show resolved Hide resolved
@F3n67u
Copy link
Member

F3n67u commented Jun 28, 2022

This test is top 1 flaky test in all last week. If we could not make progress to fix this flaky test, so you mind mark this test as flaky? https://github.com/nodejs/reliability/issues

Hi @ShogunPanda. I mark this test as flaky. We could remove this mark when we fixed this flaky problem. #43597

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flaky-test Issues and PRs related to the tests with unstable failures on the CI. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants