-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: fix sequential test-net-connect-local-error #13064
test: fix sequential test-net-connect-local-error #13064
Conversation
@@ -14,7 +14,7 @@ client.on('error', common.mustCall(function onError(err) { | |||
assert.strictEqual(err.code, 'ECONNREFUSED'); | |||
assert.strictEqual( | |||
err.localPort, | |||
common.PORT, | |||
common.PORT + 1, | |||
`${err.localPort} !== ${common.PORT} in ${err}` |
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: fix assertion fail message
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.
LGTM with nit (about the assert message--either fix it or simply remove it) addressed and green CI.
Stress whole |
Still flaky (1 out of 100 runs of the whole
|
Could it be because of this? |
Good catch, that's probably it... As I see it we have several options:
|
About no. 2, wouldn't |
I don't think so because here we don't actually bind the port. |
What if we use some IANA reserved ports? How much of a guarantee could we have that those ports won't be used by anything else? Could we define some port constants that indicate "hey, we should never directly bind to this port in any test ever"? |
That was my thought when we started with #12964, also a valid solution. |
Flying a test balloon: |
So stress test on /cc @nodejs/testing |
I'm confused. If the unexpected error we're receiving is |
The expected error is That is why we need a destination port that will never be bound and will always cause |
Is there any chance at all that the solution is to call |
I'll try |
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.
technical blocking until others reapprove code smell removed
Cross-ref: #13033 |
significant change from original approved approach, not sure how I feel about it yet...more in a subsequent comment
Not sure how I feel about this. I suspect /cc @nodejs/testing for other opinions... |
Maybe I'm missing something but, considering that the purpose of this test is checking that the properties of the error object are properly set, why not consider For the record, I consider |
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.
Accept EADDRINUSE
port: common.PORT + 1, | ||
localPort: common.PORT, | ||
port: common.PORT, | ||
localPort: common.PORT + 1, | ||
localAddress: common.localhostIPv4 | ||
}); | ||
|
||
client.on('error', common.mustCall(function onError(err) { | ||
assert.strictEqual(err.syscall, 'connect'); | ||
assert.strictEqual(err.code, 'ECONNREFUSED'); |
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.
@sebastianplesciuc IMHO @santigimeno it right, we should just add an if for EADDRINUSE
(or err.code in ['ECONNREFUSED', 'EADDRINUSE']
)
/cc @Trott @cjihrig
`${err.localAddress} !== ${common.localhostIPv4} in ${err}` | ||
); | ||
assert.strictEqual(err.localPort, common.PORT + 1); | ||
assert.strictEqual(err.localAddress, common.localhostIPv4); | ||
assert.strictEqual( | ||
err.message, | ||
`connect ECONNREFUSED ${err.address}:${err.port} ` + |
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.
If we decide to accept EADDRINUSE
this'll need to be adjusted too
Ohh, definatly a code smell 👃...
That's sounds reasonable. Also in the near future (#13100) we'll fix |
@refack fixed. Let me know if it's ok. |
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.
LGTM, let's see a CI and another stress
PR CI: https://ci.nodejs.org/job/node-test-commit/10046/ |
assert.strictEqual( | ||
err.message, | ||
`connect ECONNREFUSED ${err.address}:${err.port} ` + | ||
`connect ${err.code} ${err.address}:${err.port} ` + |
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.
Are we 100% sure that ECONNREFUSED
and EADDRINUSE
return the same exact error message other than the err.code
and that therefore this line is correct?
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.
AFACT they come from the same mechanism.
I tried to stress this, but didn't want to hog the freeBSD machine so only run 50 cycles.
Last time we saw 1 in a 100 give the EADDRINUSE
.
So worst case we have a flake and some good comments and bread crumbs to dig further.
@@ -3,28 +3,21 @@ const common = require('../common'); | |||
const assert = require('assert'); | |||
const net = require('net'); | |||
|
|||
const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; |
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.
Can we add a comment here explaining why EADDRINUSE
is included? Otherwise, someone will come across the test in 8 months and remove EADDRINUSE
and we'll be right back where we are. :-D
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.
I need your advice on a proper comment for this. Is this ok?
// EADDRINUSE is expected to occur on FreeBSD
// Please see https://github.com/nodejs/node/issues/13055 for more details
Not really sure if you guys approve of URLs in code comments.
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 that's fine @sebastianplesciuc . Full URL is great.
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.
Format suggested is fine. EADDRINUSE
doesn't occur every time, just sometimes, right? EADDRINUSE is expected
makes it sound like it occurs every time. Maybe EADDRINUSE can occur on FreeBSD.
?
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.
Whoops, I'm too late! :-D Anyway, the comment is fine. What I suggested is just a nit. It can be ignored.
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.
LGTM with #13064 (comment) addressed
Fixed sequential test-net-connect-local-error by swapping port and localPort in net.connect options. Fixes: #13055
@@ -3,28 +3,23 @@ const common = require('../common'); | |||
const assert = require('assert'); | |||
const net = require('net'); | |||
|
|||
// EADDRINUSE is expected to occur on FreeBSD | |||
// Please see https://github.com/nodejs/node/issues/13055 for more details |
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.
Change to:
Ref: https://github.com/nodejs/node/issues/13055
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.
NM. I'll do it.
Fixed sequential test-net-connect-local-error by swapping port and localPort in net.connect options. PR-URL: nodejs#13064 Fixes: nodejs#13055 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
Landed in 3429c90 |
Post land CI: https://ci.nodejs.org/job/node-test-commit/10071/ |
Fixed sequential test-net-connect-local-error by swapping port and localPort in net.connect options. PR-URL: #13064 Fixes: #13055 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
Fixed sequential test-net-connect-local-error by swapping port and localPort in net.connect options. PR-URL: #13064 Fixes: #13055 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
Fixed sequential test-net-connect-local-error by swapping port and localPort in net.connect options. PR-URL: #13064 Fixes: #13055 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
Fixed sequential test-net-connect-local-error by swapping port and localPort in net.connect options.
Fixes: #13055
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test