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 changing common.PORT to use 0 within the test-cluster-dgram.reus… #12932

Closed
wants to merge 8 commits into from

Conversation

akopcz2
Copy link

@akopcz2 akopcz2 commented May 9, 2017

…e.js

Checklist
  • [x ] make -j4 test (UNIX), or vcbuild test (Windows) passes
  • [x ] tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label May 9, 2017
@mscdex mscdex added cluster Issues and PRs related to the cluster subsystem. dgram Issues and PRs related to the dgram subsystem / UDP. labels May 9, 2017
@@ -37,4 +37,4 @@ function close() {
}

for (let i = 0; i < 2; i++)
dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next);
dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(0, next);
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be better if you remove the for loop and have two separate bind() calls. The outer call to bind() would use port 0 and the other call would happen in the callback for that bind(), using .address().port to get the port of the outer bind and reuse it.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your reply!
I made the changes that you requested in your comment above and have implemented them in my latest commit, hopefully correctly.

for (let i = 0; i < 2; i++)
dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(0, next);
const socket = dgram.createSocket({type:'udp4', reuseAddr: true})
.bind(0, common.mustCall(()=>{
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this pass make lint?

Copy link
Author

Choose a reason for hiding this comment

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

Commit 7db0f60 Passes lint. Did not realize that my linter was misconfigured in my current workspace. Thanks for this catch!

Trott
Trott previously requested changes May 11, 2017
dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next);
const socket = dgram.createSocket({type: 'udp4', reuseAddr: true})
.bind(0, common.mustCall(() => {
socket.bind(this.address().port, next);
Copy link
Member

@Trott Trott May 11, 2017

Choose a reason for hiding this comment

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

This runs bind twice on the socket but the existing test runs createSocket() twice and this runs it only once. But running it twice is what is actually being tested here, I think. So this invalidates the test, I think.

Copy link
Author

@akopcz2 akopcz2 May 11, 2017

Choose a reason for hiding this comment

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

@Trott Thanks! That makes sense. Would calling another socket inside the callback here work e4f250a ?

dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next);
const socket = dgram.createSocket({type: 'udp4', reuseAddr: true})
.bind(0, common.mustCall(() => {
const socket2 = socket();
Copy link
Contributor

Choose a reason for hiding this comment

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

socket() looks incorrect to me. Should this be dgram.createSocket()?

Copy link
Author

@akopcz2 akopcz2 May 11, 2017

Choose a reason for hiding this comment

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

I was under the impression that calling socket() was the same as dgram.createSocket since I declared socket as a const. I updated the code here 41292b7

@addaleax
Copy link
Member

ping @Trott @cjihrig

@akopcz2 This needs to be rebased against master, too.

@cjihrig cjihrig dismissed their stale review May 19, 2017 21:46

review dismissed

const socket = dgram.createSocket({type: 'udp4', reuseAddr: true})
.bind(0, common.mustCall(() => {
const socket2 = dgram.createSocket({type: 'udp4', reuseAddr: true})
socket.bind(this.address().port, next);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not so happy about this rebind, you could just do next.call(this).

@refack
Copy link
Contributor

refack commented May 20, 2017

IMHO all the literal 2s should be parameterized. And maybe also restore the socket creating loop inside the bind callback for (let i = 1; i < N; i++) {create sockets}

@refack
Copy link
Contributor

refack commented May 20, 2017

P.S. @akopcz2 thank you very much for your contribution 🥇

@Trott Trott dismissed their stale review May 20, 2017 05:00

nit addressed

@akopcz2
Copy link
Author

akopcz2 commented May 20, 2017

@refack Absolutely. Thanks for the explanation!

@Trott
Copy link
Member

Trott commented May 20, 2017

Looks like this was handled simultaneously in 6b1819c / #12901 which has landed. I'm going to close this. Thanks for the contribution, @akopcz2! Sorry it didn't land on master. Hope the experience hasn't been too discouraging and we'll see more from you!

@Trott Trott closed this May 20, 2017
@akopcz2
Copy link
Author

akopcz2 commented May 20, 2017

@Trott No worries...and absolutely. Didn't realize contributing would be this fun. Hopefully next time I can get a change in to master 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem. dgram Issues and PRs related to the dgram subsystem / UDP. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants