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: use random ports where possible #7045

Merged
merged 1 commit into from
Jun 11, 2016

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented May 29, 2016

Checklist
  • tests and code linting passes
  • the commit message follows commit guidelines
Affected core subsystem(s)
  • test
Description of change

This helps to prevent issues where a failed test can keep a bound socket open long enough to cause other tests to fail with EADDRINUSE because the same port number is used.

I should note that this commit still leaves some tests unmodified (mostly cluster-related and debugger-related tests), because either #7043 needs to land first or the solution is a little trickier than with typical tests. There are also some tests that use common.PORT but they do not pass it to .bind() or .listen(), so those should be safe to keep as-is.

@mscdex mscdex added the test Issues and PRs related to the tests. label May 29, 2016
@mscdex
Copy link
Contributor Author

mscdex commented May 29, 2016

@bnoordhuis
Copy link
Member

Apparently the diff is too big to review through GH's web interface. Reviewing it locally, it mostly LGTM but we'll still need tests that exercise binding to a specific port. I suppose that's covered by tests outside test/parallel.

@mscdex
Copy link
Contributor Author

mscdex commented Jun 1, 2016

@mscdex
Copy link
Contributor Author

mscdex commented Jun 1, 2016

/cc @nodejs/testing

@orangemocha
Copy link
Contributor

The idea of using random ports makes me a bit nervous, in that it could introduce new non-deterministic failures.

IMO a better way to deal with the EADDRINUSE would be to ensure in the test runner that all processes are terminated between sequential tests.

@mscdex
Copy link
Contributor Author

mscdex commented Jun 7, 2016

@orangemocha The problem is with the parallel tests, not the sequential tests

@mscdex
Copy link
Contributor Author

mscdex commented Jun 7, 2016

/cc @nodejs/collaborators Thoughts?

@mcollina
Copy link
Member

mcollina commented Jun 7, 2016

Happy with it as long as some tests are retained to use a default port. We need to test that as well.

@mscdex
Copy link
Contributor Author

mscdex commented Jun 7, 2016

@bnoordhuis @mcollina FWIW there are tests in sequential/ that use/test common.PORT.

@mcollina
Copy link
Member

mcollina commented Jun 7, 2016

LGTM (it's impossible to review completely) if CI passes.

What's the problem with ARM?

@mscdex
Copy link
Contributor Author

mscdex commented Jun 7, 2016

@mcollina Just CI infrastructure issues I guess. Another CI run for the heck of it: https://ci.nodejs.org/job/node-test-pull-request/2945/

@mcollina
Copy link
Member

mcollina commented Jun 7, 2016

that run errored badly:/

@mscdex
Copy link
Contributor Author

mscdex commented Jun 7, 2016

@mscdex
Copy link
Contributor Author

mscdex commented Jun 7, 2016

CI is still green except for a CI infrastructure failure on Windows. Retry on Windows is green: https://ci.nodejs.org/job/node-test-commit-windows-fanned/2886/

@mcollina
Copy link
Member

mcollina commented Jun 7, 2016

LGTM

@rvagg
Copy link
Member

rvagg commented Jun 8, 2016

Even taking into account @orangemocha's concerns, I'd love to have everything move to randomized ports as it would give us the ability to do some hardware reuse in CI. An example situation where this might be handy is if we were to migrate away from Jenkins, or even try to upgrade to Jenkins v2, we could be running many (not all, some don't have capacity) of our machines attached to both old and new CI master.

this lgtm me anyway

@mscdex
Copy link
Contributor Author

mscdex commented Jun 8, 2016

@orangemocha Since this is affecting only parallel/ tests and there are sequential/ tests that still use/test common.PORT, is this PR ok with you?

@orangemocha
Copy link
Contributor

Yes, go ahead. Thank you.

This helps to prevent issues where a failed test can keep a bound
socket open long enough to cause other tests to fail with EADDRINUSE
because the same port number is used.

PR-URL: nodejs#7045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
@mscdex mscdex merged commit 2bc7841 into nodejs:master Jun 11, 2016
@mscdex mscdex deleted the test-use-random-ports branch June 11, 2016 02:38
evanlucas pushed a commit that referenced this pull request Jun 16, 2016
This helps to prevent issues where a failed test can keep a bound
socket open long enough to cause other tests to fail with EADDRINUSE
because the same port number is used.

PR-URL: #7045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
@evanlucas evanlucas mentioned this pull request Jun 16, 2016
@MylesBorins
Copy link
Contributor

@mscdex would you be willing to backport this to v4.x?

mscdex added a commit to mscdex/io.js that referenced this pull request Jul 13, 2016
This helps to prevent issues where a failed test can keep a bound
socket open long enough to cause other tests to fail with EADDRINUSE
because the same port number is used.

PR-URL: nodejs#7045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
This helps to prevent issues where a failed test can keep a bound
socket open long enough to cause other tests to fail with EADDRINUSE
because the same port number is used.

PR-URL: #7045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
This helps to prevent issues where a failed test can keep a bound
socket open long enough to cause other tests to fail with EADDRINUSE
because the same port number is used.

PR-URL: #7045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
This helps to prevent issues where a failed test can keep a bound
socket open long enough to cause other tests to fail with EADDRINUSE
because the same port number is used.

PR-URL: #7045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
@MylesBorins MylesBorins mentioned this pull request Jul 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants