-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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 localhost error in test-dns-ipv6 #8254
Conversation
common.skip('localhost does not resolve to ::1'); | ||
return; | ||
} | ||
throw 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.
This should assert instead of throw
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.
This should assert instead of throw
Why is that? (Not trolling; honest question. If there's an err
object, then that's basically an exception, not a test failure per se. Might be system DNS misconfiguration, DNS server unavailability, network problems...)
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 think this should be assert.ifError()
.
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'm happy to change it, but if assert.ifError()
is just this:
assert.ifError = function(err) { if (err) throw err; };
what is the reason for having the extra layer of indirection?
This looks incorrect to me. It will skip these tests if Is there an issue this is trying to fix? Can you link to that? |
@Trott Yep you're right! I got confused. The problem we were having is that some machines didn't have the
Obviously you could say that this is a machine issue, but I'm pretty sure this is the default for this machine, so it'd be nice to handle the failure in this test. Also I agree it's not ideal to skip the entire test if one of the subtests has an issue, but I'm not aware of any mechanism for skipping subtests (in fact I don't think we've implemented subtests in node, although I know npm has them). |
e1645a2
to
961fa01
Compare
Would the solution be to change line 182 from this: if (err) throw err; To this?: if (err) {
if (err.code === 'ENOTFOUND') {
return done();
}
throw err;
} |
That does indeed stop the test from failing, but it also basically hides the fact that the test didn't actually pass due to I understand there may not be any better solution. |
961fa01
to
c5dd0cd
Compare
I think the problem is that the test is faulty. The test is making an assumption about a system that isn't actually true on many default Linux variants as we've seen in other tests and now we're seeing in this one with AIX. The test amounts to "If you look up the IPv6 resolution for To that end, I'd propose that although still faulty, this is an improvement: "If you look up the IPv6 resolution for To that end, I'd change the code I wrote above to this: if (err) {
assert.strictEqual(err.code, 'ENOTFOUND');
return done();
} That makes it a little more clear that we're not skipping the test so much as checking an alternative acceptable result. |
By the way, you may be wondering why you are seeing this on AIX while it never caused problems with the Linux variants that also do not have the The answer is because the |
@Trott That makes a lot of sense. I'll make that change and add a comment to note down why |
a92184d
to
058abe9
Compare
@Trott Updated, PTAL |
It may be worthwhile to expand the code comment in the test to explain a bit more. Specifically, calling out something like:
Or some such... Otherwise, LGTM |
058abe9
to
17f3793
Compare
If ::1 can't be resolved, the test should still pass.
17f3793
to
1d221a3
Compare
Sounds good to me, updated. |
LGTM |
Looks like CI passed except for a Git checkout issue on linuxone. As the internet tests aren't actually run, I guess the only thing the CI really tells us is that the linter passed. |
Landed in 3504a98 |
If ::1 can't be resolved, the test should still pass. PR-URL: nodejs#8254 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
If ::1 can't be resolved, the test should still pass. PR-URL: nodejs#8254 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
If ::1 can't be resolved, the test should still pass. PR-URL: #8254 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
If ::1 can't be resolved, the test should still pass. PR-URL: #8254 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
If ::1 can't be resolved, the test should still pass. PR-URL: #8254 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
If ::1 can't be resolved, the test should still pass. PR-URL: #8254 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
If ::1 can't be resolved, the test should still pass. PR-URL: #8254 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
test
Description of change
If localhost doesn't resolve to ::1 in IPv6, we should skip the test.
This is the same fix as 814b8c3 (#7766)
cc: @Trott