-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 dgram cd address empty test #12929
Conversation
Is the added complexity here better than just keeping the test simple and moving to Also: At least technically, I don't think this gets rid of the port collision issue that |
(Also: I would expect |
I appreciate the comments, either way, is fine with me also. I followed the algorithm from another test which is also on your list, commit d289678 , |
@Trott Also corrected the missing newline at the end of the file. Nice catch. |
|
||
portGetter.close(); | ||
})); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: missing new line at the end of file.
I'm not sure either, as @Trott said this doesn't completely remove port collisions and makes the test harder to grok. |
@lpinca Ok, I'll remove the changes and move the tests to sequential. |
As I wrote in my last comment I think the test can be left as is. There is no need to move it sequential. client.send(buf, common.PORT, onMessage); The code above bind the socket on a random port. |
I apologize, misunderstood your comment. I'll close the PR. |
No problem. Also wait for other collaborators feedback, maybe I am missing something :) |
Sorry, I am super new. I'll reopen the PR. |
It is possible for these dgram tests to bind to the port to prevent port collisions. The socket would end up sending to itself and just ignore the data. It adds pretty minimal complexity, and allows the tests to stay in parallel. |
@arturgvieira, @cjihrig is suggesting something like this diff --git a/test/parallel/test-dgram-send-callback-buffer-empty-address.js b/test/parallel/test-dgram-send-callback-buffer-empty-address.js
index 67e64d6bfe..5b3b1c41a1 100644
--- a/test/parallel/test-dgram-send-callback-buffer-empty-address.js
+++ b/test/parallel/test-dgram-send-callback-buffer-empty-address.js
@@ -14,4 +14,4 @@ const onMessage = common.mustCall(function(err, bytes) {
client.close();
});
-client.send(buf, common.PORT, onMessage);
+client.bind(0, () => client.send(buf, client.address().port, onMessage)); |
@lpinga Understood and it seems like a good way to go, I will go ahead and update the PRs making that change. |
Replaced common.PORT in the following test. test-dgram-send-callback-buffer-empty-address.js Ref: #12376
@lpinca All done, updated the PRs with the change requested. |
@@ -14,4 +14,4 @@ const onMessage = common.mustCall(function(err, bytes) { | |||
client.close(); | |||
}); | |||
|
|||
client.send(buf, common.PORT, onMessage); | |||
client.bind(0, () => client.send(buf, client.address().port, onMessage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea to wrap the callback in common.mustCall()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad idea. onMessage()
is wrapped in a mustCall()
, so in this case not strictly necessary. No strong preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah, if onMessage
is already wrapped then the additional wrapping suggested by me above is actually not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I also find common.mustCall()
a bit redundant here which is the reason why I didn't suggest it in the first place.
Landed in 4c84734. |
Replaced common.PORT in the following test.
test-dgram-send-callback-buffer-empty-address.js
Ref: #12376
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test dgram