-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Conversation
CI: https://ci.nodejs.org/job/node-test-pull-request/10909/ (do we have one for the internet tests?) |
test/common/dns.js
Outdated
@@ -287,4 +287,51 @@ function writeDNSPacket(parsed) { | |||
})); | |||
} | |||
|
|||
module.exports = { types, classes, writeDNSPacket, parseDNSPacket }; | |||
|
|||
const addresses = { |
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 am not quite sure if common/dns
is the best place to put this. Also pending docs.
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 it’s specific to test/internet
, it might be better live in a file there (similar to what test/async-hooks
has)?
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 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
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.
Alternatively just add another module, test/common/internet.js
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 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.
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.
💯
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 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(() => { |
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.
Improving the test at the same time? Nice!
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.
@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..
Nope, added to #16390 (comment) |
Do all these defaults now work behind the GFW? |
@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 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 (FWIW, I am with China Mobile in Hangzhou when I work on this PR). |
test/internet/test-dns.js
Outdated
|
||
req.oncomplete = function(err, domains) { | ||
assert.strictEqual(err, 0); | ||
console.log('nodejs.org = ', domains); | ||
console.log(`${addresses.INET4_HOST} = `, domains); |
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.
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())); |
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.
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); | ||
|
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.
How about defining a constant for ::1
as well?
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.
localhost
is defined for IPv4 and IPv6:
Lines 183 to 185 in 27e12e7
let localhostIPv4 = null; | |
exports.localIPv6Hosts = ['localhost']; |
test/common/dns.js
Outdated
// An accessible IPv4 DNS server | ||
DNS4_SERVER: '8.8.8.8' | ||
}; | ||
|
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 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?
@refack @addaleax @gibfahn @gireeshpunathil I've move the addresses to a new module I'll defer the other constants e.g. |
@@ -498,6 +498,40 @@ Returns the result of | |||
Returns the result of | |||
`fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`. | |||
|
|||
## Internet Module |
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: Can you please add an entry for this new module to the table of contents near the start of this file?
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.
@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.
49e706b
to
b28c152
Compare
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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #16390 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in f2cb78c...5dca787, thanks! |
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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #16390 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Should this be backported to |
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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#16390 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #16390 Backport-PR-URL: #19706 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
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 tonodejs.org
.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test