Skip to content

test: add non-internet resolveAny tests - #13883

Closed
addaleax wants to merge 2 commits into
nodejs:masterfrom
addaleax:dns-tests
Closed

test: add non-internet resolveAny tests#13883
addaleax wants to merge 2 commits into
nodejs:masterfrom
addaleax:dns-tests

Conversation

@addaleax

Copy link
Copy Markdown
Member

This is a bit of a check to see how people feel about having this kind of test.

Ref: #13137

/cc @nodejs/testing @XadillaX

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

test/dns

@addaleaxaddaleax added dns Issues and PRs related to the dns subsystem. dont-land-on-v4.x test Issues and PRs related to the tests. labels Jun 22, 2017
@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label Jun 22, 2017
@refack

Copy link
Copy Markdown
Contributor

I'm not against the concept. (personally would prefer a tested implementation but the only one I found is https://www.npmjs.com/package/dnsd 😕 and it's kind of dormant).

@Trott

Copy link
Copy Markdown
Member

So this allows a test double for the DNS server? Seems like a 👍 idea to me. Certainly better than not running the tests in CI ever!

@addaleax

Copy link
Copy Markdown
MemberAuthor

@Trott Yes, it’s essentially an implementation of a small fake DNS server. One of the nice things about it is that we can use it to send invalid responses as well, or make testing less dependent on external factors like what kind of records exist for a specific hard-coded domain.

@refack If you want to put the work in it, sure, try to build something with dnsd and open a PR.

@gibfahn

Copy link
Copy Markdown
Member

+1 on this (needs something in test/common/README.md, but I'm pretty sure @addaleax is making sure everyone's okay with this first).

personally would prefer a tested implementation

Maybe, but I assume a tailored one can be much more concise (I assume we don't need a full DNS server).

Comment threadtest/common/dns.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a specific rule that can be turned off here?

@TrottTrottJun 23, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If &~ 0xC000 on the next line is changed to & ~0xC000, then we don't need this ESLint disable comment.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Eslint is unhappy about both the missing space before ~ and after &, so it’s two separate rules.

If &~ 0xC000 on the next line is changed to & ~0xC000, then we don't need this ESLint disable comment.

Right, but I’d consider &~ more idiomatic for bit-twiddling code (because it removes an extra thought iteration, from “bitwise and with some oddly generated mask” to “it’s just removing those bits”).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about:

constkLengthMask=0xC0;constkOffsetMask=~0xC000;

I get the idiom, but I have to use my fingers to figure out 0xC000 === 0o‭140000‬ == 0b1100000000000000 === 0x3 << 14 and my mind just has to do that. Using a const will allow me to abstract it away 😅

Comment threadtest/common/dns.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not that it really matters, but why not just use standard quote characters here?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

But these are the proper quotation marks? ;) (All trolling aside, I’m just used to typing these if it’s not for code, that’s all.)

Comment threadtest/common/dns.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are a couple uses of split() on single characters in this PR. Would the string version work (split('.'))? It seems more readable.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@cjihrig I just literally forgot that split can work with plain strings. Updated :)

@refack

Copy link
Copy Markdown
Contributor

@refack If you want to put the work in it, sure, try to build something with dnsd and open a PR.

Let's do the opposite, publish this as dns-mock (add me and I'll write some tests).

Comment threadtest/common/dns.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about:

constkLengthMask=0xC0;constkOffsetMask=~0xC000;

I get the idiom, but I have to use my fingers to figure out 0xC000 === 0o‭140000‬ == 0b1100000000000000 === 0x3 << 14 and my mind just has to do that. Using a const will allow me to abstract it away 😅

Comment threadtest/common/dns.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😵

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

·@refack This is not a very helpful comment, I have no idea what you are trying to say.

@refackrefackJun 26, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please define this as a const so it's more obvious what are flags you want.

Comment threadtest/common/dns.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you need this?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Yes, the linter complains otherwise.

@TrottTrottJun 27, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You could replace it with /* eslint-disable required-modules */ at the top of the file the way it is in test/common/wpt.js. I think I'd prefer that. If it's leaking globals, then any tests that use it will complain, so we're covered without importing the common module.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@Trott Sorry for being so late, I’ve updated this PR with eslint-disable required-modules

@jasnell

Copy link
Copy Markdown
Member

I'm generally +1 on having this (and love seeing this kind of work) but my one concern is that there are no tests to verify that the common/dns.js script is itself exhibiting correct behavior. That is, if the test server is buggy, we could end up with buggy dns tests if we are not careful. I'm not sure if there's anything we can actually do about it, but it is definitely something to keep in mind.

@refack

refack commented Jul 10, 2017

Copy link
Copy Markdown
Contributor

I'm not sure if there's anything we can actually do about it, but it is definitely something to keep in mind.

If we run /test/internet/ on a regular basis we could infer that the net-less tests are correct.

@addaleax

Copy link
Copy Markdown
MemberAuthor

Just to mention it again, the main scenario that prompted this is checking how our code handles invalid responses, something we won’t be able to do with a “proper” DNS server.

@jasnell

Copy link
Copy Markdown
Member

Yeah, good point :-)

@addaleax

Copy link
Copy Markdown
MemberAuthor

Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
This is a bit of a check to see how people feel about having this kind
of test.
Ref: nodejs#13137
PR-URL: nodejs#13883
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@addaleax

Copy link
Copy Markdown
MemberAuthor

Added c-ares/c-ares@18ea996 because both the test proposed here and our existing internet tests (make test-internet) are currently broken after the security release.

CI is green: https://ci.nodejs.org/job/node-test-commit/11128/

@addaleax

Copy link
Copy Markdown
MemberAuthor

Landed in e76c49d, 69f653d

@nodejs/lts The first commit here (e76c49d) should make it to v4.x and v6.x, it fixes a bug from this month’s security release. I’ve added lts-watch labels, is that enough? Unfortunately the tests here themselves depend on v8.x-only features of Node. (Sorry for the mess, I didn’t plan it that way when I opened the PR. 😄)

addaleax added a commit that referenced this pull request Jul 24, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax added a commit that referenced this pull request Jul 24, 2017
This is a bit of a check to see how people feel about having this kind
of test.
Ref: #13137
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@addaleaxaddaleax mentioned this pull request Jul 24, 2017
@addaleaxaddaleax mentioned this pull request Aug 2, 2017
MylesBorins pushed a commit that referenced this pull request Aug 16, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Aug 16, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorinsMylesBorins mentioned this pull request Aug 16, 2017
MylesBorins pushed a commit that referenced this pull request Aug 16, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 3, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 5, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
rvagg pushed a commit to rvagg/io.js that referenced this pull request Sep 13, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: nodejs#13883
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorinsMylesBorins mentioned this pull request Sep 20, 2017
BridgeAR pushed a commit that referenced this pull request Oct 2, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax added a commit to addaleax/ayo that referenced this pull request Oct 4, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: nodejs/node#13883
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Oct 25, 2017
Original commit message:
ares_parse_naptr_reply: make buffer length check more accurate
9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check
for records parsed by `ares_parse_naptr_reply()`. However, that
function is designed to parse replies which also contain non-NAPTR
records; for A records, the `rr_len > 7` check will fail as there
are only 4 bytes of payload.
In particular, parsing ANY replies for NAPTR records was broken
by that patch.
Fix that by moving the check into the case in which it is already
known that the record is a NAPTR record.
Ref: c-ares/c-ares@18ea996
PR-URL: #13883
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorinsMylesBorins mentioned this pull request Oct 25, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dnsIssues and PRs related to the dns subsystem.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@addaleax@refack@Trott@gibfahn@jasnell@cjihrig@MylesBorins@nodejs-github-bot