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: fix flaky test #23811

Closed
wants to merge 1 commit into from
Closed

test: fix flaky test #23811

wants to merge 1 commit into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Oct 21, 2018

This commit fixes test-tls-set-secure-context.js. The test was making one long lasting HTTP connection, followed by a number of shorter lived connections. However, it was possible that the connections were not received in the desired order. This commit ensures that the long lasting connection is established before making any other connections.

Fixes: #23807

Before this change, the command tools/test.py -j 8 --repeat 1000 test/parallel/test-tls-set-secure-context.js failed approximately 1% of the time for me locally. With this change, I haven't seen a failure after two such runs.

cc: @targos

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Oct 21, 2018
@refack
Copy link
Contributor

refack commented Oct 21, 2018

test/parallel/test-tls-set-secure-context.js Show resolved Hide resolved
server.close();
}

setImmediate(makeRemainingRequests);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think we can simply call the function as it will just postpone itself anyway.

This commit fixes test-tls-set-secure-context.js. The test was
making one long lasting HTTP connection, followed by a number of
shorter lived connections. However, it was possible that the
connections were not received in the desired order. This commit
ensures that the long lasting connection is established before
making any other connections.
async function makeRemainingRequests() {
// Wait until the first request is guaranteed to have been handled.
if (!firstResponse) {
return setImmediate(makeRemainingRequests);
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a dummy EventEmitter to emit an event when firstResponse is set instead of polling for it and call makeRemainingRequests when the event is emitted?

@lundibundi lundibundi added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 23, 2018
@lundibundi
Copy link
Member

Trott pushed a commit to Trott/io.js that referenced this pull request Oct 24, 2018
This commit fixes test-tls-set-secure-context.js. The test was
making one long lasting HTTP connection, followed by a number of
shorter lived connections. However, it was possible that the
connections were not received in the desired order. This commit
ensures that the long lasting connection is established before
making any other connections.

PR-URL: nodejs#23811
Fixes: nodejs#23807
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@Trott
Copy link
Member

Trott commented Oct 24, 2018

Landed in b794f58.

@lpinca Regarding your comment: Nit that can be ignored? Or something that should be done in a subsequent PR? If more than a nit, you'll open the PR?

@Trott Trott closed this Oct 24, 2018
@lpinca
Copy link
Member

lpinca commented Oct 24, 2018

Yes, it can be ignored or addressed in another PR. Thank you.

@cjihrig cjihrig deleted the test-fix branch October 24, 2018 12:27
targos pushed a commit that referenced this pull request Oct 24, 2018
This commit fixes test-tls-set-secure-context.js. The test was
making one long lasting HTTP connection, followed by a number of
shorter lived connections. However, it was possible that the
connections were not received in the desired order. This commit
ensures that the long lasting connection is established before
making any other connections.

PR-URL: #23811
Fixes: #23807
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate flaky test-tls-set-secure-context
8 participants