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: replace port in net immediate finish test #12996

Closed
wants to merge 1 commit into from
Closed

test: replace port in net immediate finish test #12996

wants to merge 1 commit into from

Conversation

arturgvieira-zz
Copy link

@arturgvieira-zz arturgvieira-zz commented May 12, 2017

Replaced common.PORT in the following test.
test-net-connect-immediate-finish.js

Ref: #12376

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • 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 May 12, 2017

const client = net.connect({host: '***', port: common.PORT});
// port 8080 is hardcoded since this does not create a network connection
const client = net.connect({host: '***', port: 8080});
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a good try, but IMHO it's too arbitrary, you could just use 0.

A (controversial) other way is to copy what we did in 12964 but only do that as an exercise!

Copy link
Author

Choose a reason for hiding this comment

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

@refack Sounds good, I'll have the changes made in a quick update.

@arturgvieira-zz
Copy link
Author

All done, updated the port to 0 (zero) and made the same update to the comment.

@mscdex mscdex added the net Issues and PRs related to the net subsystem. label May 12, 2017
@addaleax
Copy link
Member

I hate to say it, but I don’t think 0 is a better choice than 8080. 0 is not a valid port to connect to, but 8080 and common.PORT are – I think your original approach of using a fixed but valid port is better (or at least more readable) here.

@gibfahn
Copy link
Member

gibfahn commented May 15, 2017

Does connecting to an invalid port raise an error? If so that might work well, that way if the connection does happen the test will fail.

@refack
Copy link
Contributor

refack commented May 16, 2017

@arturgvieira after the long discussion we had in #12964 (also about a test that should immediately fail), I think best solution is to keep the use of common.PORT and move the test to /sequential/.

Maybe next PR should actually merge this test with https://github.com/nodejs/node/blob/master/test/parallel/test-net-connect-local-error.js. that one tests for an error in the port and this one in the hostname

@arturgvieira-zz
Copy link
Author

@refack Sounds good, I will revert the changes and move this test to sequential.

@refack
Copy link
Contributor

refack commented May 16, 2017

@arturgvieira I just landed #12964 IMHO you can copy the old test code into test/sequential/test-net-connect-local-error.js. Unless the others object.

@refack refack self-assigned this May 16, 2017
Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

moving to /sequential/


const client = net.connect({host: '***', port: common.PORT});
// port 0 is hardcoded since this does not create a network connection
const client = net.connect({host: '***', port: 0});
Copy link
Contributor

Choose a reason for hiding this comment

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

Declare a const unfindable_host = '***'

@arturgvieira-zz arturgvieira-zz changed the title test: replace port in net immediate finish test test: move net immediate finish test to sequential May 16, 2017
@arturgvieira-zz
Copy link
Author

All done, I replaced the host string literal with a constant, reverted the changes so that this test uses common.PORT and moved the test to sequential.

@arturgvieira-zz
Copy link
Author

@refack You want to merge this test with test/sequential/test-net-connect-local-error.js correct?

@refack
Copy link
Contributor

refack commented May 16, 2017

I approved the important changes. About merging, let's get a second opinion.
/cc @Trott @addaleax @nodejs/testing

@arturgvieira-zz
Copy link
Author

Sounds good.

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.

There is no need to move this to sequential.

Replaced common.PORT in the following test.
test-net-connect-immediate-finish.js

Ref: #12376
@arturgvieira-zz arturgvieira-zz changed the title test: move net immediate finish test to sequential test: replace port in net immediate finish test May 16, 2017
@arturgvieira-zz
Copy link
Author

Ok, I reverted that last change.

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.

Port 0 is not OK for this test for the reasons outlined by @addaleax.

@Trott
Copy link
Member

Trott commented May 16, 2017

I think this test may not need any changes at all. It's fine as is. The only change it might need is a comment explaining why using common.PORT here is actually OK. (Or change it to a hard coded value like 8080 and add that comment.)

@arturgvieira-zz
Copy link
Author

Sounds good. I'll close the PR, thanks for the review.

@arturgvieira-zz arturgvieira-zz deleted the commonPort07-branch branch May 16, 2017 19:50
@refack
Copy link
Contributor

refack commented May 16, 2017

IMHO you closed too fast, I've revived it in #13062
As we've seen tests fail because of cross-talk (#12964, #12950, #12951, #13055), so since this test needs to not connect, IMHO it's more "sanitary" to run it in /sequential/ (plus it uses common.PORT)

@refack refack removed their assignment Oct 20, 2018
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants