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: make addresses of internet tests configurable #16390

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

This PR makes the addresses used by the internet tests configurable (via NODE_TEST_* environment variables), so it's easier to verify them within a firewall.

Also this moves most google.com references to nodejs.org.

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

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Oct 22, 2017
@joyeecheung
Copy link
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/10909/ (do we have one for the internet tests?)

@@ -287,4 +287,51 @@ function writeDNSPacket(parsed) {
}));
}

module.exports = { types, classes, writeDNSPacket, parseDNSPacket };

const addresses = {
Copy link
Member Author

Choose a reason for hiding this comment

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

I am not quite sure if common/dns is the best place to put this. Also pending docs.

Copy link
Member

Choose a reason for hiding this comment

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

If it’s specific to test/internet, it might be better live in a file there (similar to what test/async-hooks has)?

Copy link
Contributor

@refack refack Oct 22, 2017

Choose a reason for hiding this comment

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

I'm not 100% sure about that... On the one hand, I'd rather see all "harness" code in common, on the other hand this should not be used by any other suite.
/ping @Trott & @nodejs/testing

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively just add another module, test/common/internet.js

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not 100% sure about that... On the one hand, I'd rather see all "harness" code in common, on the other hand this should not be used by any other suite.

I think it's not a terrible bad idea to replace other google.com references in parallel tests..also when my ISP DNS hijacks NXDOMAIN there are constant errors from parallel/test-net-connect-immediate-finish and parallel/test-net-better-error-messages-port-hostname, it would be helpful to replace those this.hostname.is.invalid with *** configured via environment variables.

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Member

@gibfahn gibfahn left a comment

Choose a reason for hiding this comment

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

LGTM with docs.

@@ -20,8 +21,8 @@ const methods = [
methods.forEach(function(method) {
const d = domain.create();
d.run(function() {
dns[method]('google.com', function() {
dns[method](addresses.INET_HOST, common.mustCall(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Improving the test at the same time? Nice!

Copy link
Member Author

Choose a reason for hiding this comment

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

@gibfahn There are so many missing common.mustCall in the internet tests...better leave it to other PRs but this is in a loop, so I thought why not :D..

@gibfahn
Copy link
Member

gibfahn commented Oct 22, 2017

(do we have one for the internet tests?)

Nope, added to #16390 (comment)

@gibfahn
Copy link
Member

gibfahn commented Oct 22, 2017

so it's easier to verify them within a firewall.

Do all these defaults now work behind the GFW?

@joyeecheung
Copy link
Member Author

joyeecheung commented Oct 23, 2017

@gibfahn In my case it works reliably when using the 114 DNS(114.114.114.114) or the Google Public DNS(8.8.8.8, I am surprised to find that it is accessible from my ISP again). Other popular public DNS behind GFW like AliDNS and DNSPod DNS all miss some records tested by test-dns.js from time to time.

With the DNS servers designated by my ISP it never works, I will have to set up those env vars using hosts behind GFW. DNS hijacking is very common behind GFW and the situation varies among different ISP and regions. Also, setting up the system to use public DNS servers does not guarantee you are actually connecting to their servers, some ISP hijacks requests to popular public DNS servers (there are traceroute reports showing that from time to time).

(FWIW, I am with China Mobile in Hangzhou when I work on this PR).


req.oncomplete = function(err, domains) {
assert.strictEqual(err, 0);
console.log('nodejs.org = ', domains);
console.log(`${addresses.INET4_HOST} = `, domains);
Copy link
Member

Choose a reason for hiding this comment

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

How about coalescing the params?


assert.doesNotThrow(() => dns.lookupService('0.0.0.0', '0', common.mustCall()));
assert.doesNotThrow(() =>
dns.lookupService('0.0.0.0', '0', common.mustCall()));
Copy link
Member

Choose a reason for hiding this comment

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

How about defining a constant for 0.0.0.0 as well?

common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(isIPv6(ip));
assert.strictEqual(family, 6);

Copy link
Member

Choose a reason for hiding this comment

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

How about defining a constant for ::1 as well?

Copy link
Member

Choose a reason for hiding this comment

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

localhost is defined for IPv4 and IPv6:

node/test/common/index.js

Lines 183 to 185 in 27e12e7

let localhostIPv4 = null;
exports.localIPv6Hosts = ['localhost'];

// An accessible IPv4 DNS server
DNS4_SERVER: '8.8.8.8'
};

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about the locality and proximity of our test systems w.r.t the system that hosts http://nodejs.org . If they are too close / under one subnet etc. how some of the tests (like dns resolution, pings, downloads etc.) are going to respond in terms of network level operations - will there be any bypasses?

@joyeecheung
Copy link
Member Author

joyeecheung commented Nov 6, 2017

@refack @addaleax @gibfahn @gireeshpunathil I've move the addresses to a new module test/common/internet.js and added documentation, PTAL.

I'll defer the other constants e.g. 0.0.0.0 to another PR (looks like a good first issue).

CI: https://ci.nodejs.org/job/node-test-pull-request/11213/

@@ -498,6 +498,40 @@ Returns the result of
Returns the result of
`fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`.

## Internet Module
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Can you please add an entry for this new module to the table of contents near the start of this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Trott Of course!

This commit introduces test/common/internet.address, which
includes a set of addresses for doing internet tests.
These addresses can be overriden using NODE_TEST_* environment
variables.
@joyeecheung joyeecheung force-pushed the inet-var branch 2 times, most recently from 49e706b to b28c152 Compare November 8, 2017 10:35
joyeecheung added a commit that referenced this pull request Nov 8, 2017
This commit introduces test/common/internet.address, which
includes a set of addresses for doing internet tests.
These addresses can be overriden using NODE_TEST_* environment
variables.

PR-URL: #16390
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
joyeecheung added a commit that referenced this pull request Nov 8, 2017
PR-URL: #16390
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@joyeecheung
Copy link
Member Author

Landed in f2cb78c...5dca787, thanks!

@joyeecheung joyeecheung closed this Nov 8, 2017
evanlucas pushed a commit that referenced this pull request Nov 13, 2017
This commit introduces test/common/internet.address, which
includes a set of addresses for doing internet tests.
These addresses can be overriden using NODE_TEST_* environment
variables.

PR-URL: #16390
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this pull request Nov 13, 2017
PR-URL: #16390
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@evanlucas evanlucas mentioned this pull request Nov 13, 2017
@MylesBorins
Copy link
Member

Should this be backported to v6.x-staging or v8.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

joyeecheung added a commit to joyeecheung/node that referenced this pull request Mar 30, 2018
This commit introduces test/common/internet.address, which
includes a set of addresses for doing internet tests.
These addresses can be overriden using NODE_TEST_* environment
variables.

PR-URL: nodejs#16390
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
joyeecheung added a commit to joyeecheung/node that referenced this pull request Mar 30, 2018
PR-URL: nodejs#16390
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
gibfahn pushed a commit that referenced this pull request Apr 11, 2018
This commit introduces test/common/internet.address, which
includes a set of addresses for doing internet tests.
These addresses can be overriden using NODE_TEST_* environment
variables.

PR-URL: #16390
Backport-PR-URL: #19706
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
gibfahn pushed a commit that referenced this pull request Apr 11, 2018
PR-URL: #16390
Backport-PR-URL: #19706
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants