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 443, not common.PORT #14928

Closed
wants to merge 1 commit into from
Closed

Conversation

maclover7
Copy link
Contributor

Ref: #12376

cc @Trott

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Aug 18, 2017
@mscdex mscdex added net Issues and PRs related to the net subsystem. tls Issues and PRs related to the tls subsystem. labels Aug 18, 2017
@tniessen
Copy link
Member

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Hmmm.... Using 0 for connect() doesn't make semantic sense. It's more likely to be a distraction than anything else. These things are throwing/emitting errors before they connect, right to anything, right? Using 0 runs the risk of it appearing that port 0 is the error-causing thing in the test and not the invalid host or whatever. For the TLS client, maybe just use port 443 because that's the usual port for such things so it shouldn't raise any attention? For the net test, any valid port should be fine. common.PORT is A-OK, or you can change it to 80 or 443 or 8080 or whatever.

@maclover7
Copy link
Contributor Author

For the TLS client, maybe just use port 443 because that's the usual port for such things so it shouldn't raise any attention?

Agree, will do

For the net test, any valid port should be fine. common.PORT is A-OK, or you can change it to 80 or 443 or 8080 or whatever.

Isn't the point here to migrate away from common.PORT? 😬

@Trott
Copy link
Member

Trott commented Aug 19, 2017

Isn't the point here to migrate away from common.PORT? 😬

Almost, but not quite. The point here is to avoid port collisions between tests that use port 0 and tests that use common.PORT.*

The easiest way to do that is to avoid listening to or connecting to common.PORT in tests that are in test/parallel.

If I understand these tests correctly, in both of these cases, the connect() fails before it actually establishes a connection. So the use of common.PORT is simply a placeholder. It could be any valid port. (We don't want to use 0 because it's invalid in connect(), so the connection might fail for that reason rather than the reason it's supposed to fail in the test.)

So, since any valid port will do as a placeholder and no actual connection occurs in these function calls (because they throw/emit errors), common.PORT is probably fine. So is any other valid value.
¯\(ツ)

* For example, if one test uses listen(0) and the OS gives it port 12346, and then a few milliseconds later, another unrelated test (running in parallel with that first test) tries listen(common.PORT) and common.PORT is also set to 12346, then the second test will fail with EADDRINUSE. This seems like it would be unlikely/infrequent, but we've seen it on CI more than once. It happens a lot less now that there's a lot less common.PORT in parallel.

@maclover7
Copy link
Contributor Author

@Trott updated -- thank you for your time walking me through this and for the great discussion! Was a little bit hard to understand the tests at first. I removed test-net-connect-immediate-finish from my commit, since it's fine that it's using common.PORT. I updated the commit message/PR title to reflect what the change is actually doing now.

@maclover7 maclover7 changed the title test: use 0, not common.PORT test: use 443, not common.PORT Aug 19, 2017
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM

@Trott
Copy link
Member

Trott commented Aug 19, 2017

@jasnell
Copy link
Member

jasnell commented Aug 23, 2017

Actually... thinking twice about this one... should the test use a commonly used hardcoded port?

@Trott
Copy link
Member

Trott commented Aug 23, 2017

Actually... thinking twice about this one... should the test use a commonly used hardcoded port?

@jasnell I think you're right. I think lines 40-44 can all be replaced with a single line:

  assert.throws(tls.connect, Done);

@maclover7
Copy link
Contributor Author

Good idea, updated @Trott @jasnell

(might be something for a later PR, but is it necessary to assert that Done is raised? seems like that's testing how tls.createSecureContext internals work, and it stuff were to break then the ciphers assertion would also break 😬 )

@Trott
Copy link
Member

Trott commented Aug 24, 2017

(might be something for a later PR, but is it necessary to assert that Done is raised? seems like that's testing how tls.createSecureContext internals work, and it stuff were to break then the ciphers assertion would also break 😬 )

I think it's still necessary because that makes sure that the function threw because of tls.createSecureContext() and not some other reason.

@Trott
Copy link
Member

Trott commented Aug 24, 2017

jasnell pushed a commit that referenced this pull request Aug 24, 2017
PR-URL: #14928
Ref: #12376
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@jasnell
Copy link
Member

jasnell commented Aug 24, 2017

Landed in d86eb5c

@jasnell jasnell closed this Aug 24, 2017
@maclover7 maclover7 deleted the jm-port branch August 25, 2017 05:27
addaleax pushed a commit to addaleax/ayo that referenced this pull request Aug 25, 2017
PR-URL: nodejs/node#14928
Ref: nodejs/node#12376
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Aug 28, 2017
PR-URL: nodejs/node#14928
Ref: nodejs/node#12376
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
PR-URL: #14928
Ref: #12376
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
PR-URL: #14928
Ref: #12376
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 20, 2017
PR-URL: #14928
Ref: #12376
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem. test Issues and PRs related to the tests. tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants