Skip to content

Commit

Permalink
test: fix test-dns-idna2008
Browse files Browse the repository at this point in the history
The DNS server will sometimes return an IPv6 address (as seen in nightly
CI from time to time). Use `family` option to force IPv4.

PR-URL: nodejs#33367
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Trott authored and codebytere committed Jun 9, 2020
1 parent 3d8ba29 commit 9f594be
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions test/internet/test-dns-idna2008.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,37 @@ const { addresses } = require('../common/internet');
const fixture = {
hostname: 'straße.de',
expectedAddress: '81.169.145.78',
dnsServer: addresses.DNS4_SERVER
dnsServer: addresses.DNS4_SERVER,
family: 4,
};

// Explicitly use well behaved DNS servers that are known to be able to resolve
// Explicitly use well-behaved DNS servers that are known to be able to resolve
// the query (which is a.k.a xn--strae-oqa.de).
dns.setServers([fixture.dnsServer]);

dns.lookup(fixture.hostname, mustCall((err, address) => {
if (err && err.errno === 'ESERVFAIL') {
assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
return;
}
assert.ifError(err);
assert.strictEqual(address, fixture.expectedAddress);
}));
dns.lookup(
fixture.hostname,
{ family: fixture.family },
mustCall((err, address) => {
if (err && err.errno === 'ESERVFAIL') {
assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
return;
}
assert.ifError(err);
assert.strictEqual(address, fixture.expectedAddress);
})
);

dns.promises.lookup(fixture.hostname).then(({ address }) => {
assert.strictEqual(address, fixture.expectedAddress);
}, (err) => {
if (err && err.errno === 'ESERVFAIL') {
assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
} else {
throw err;
}
}).finally(mustCall());
dns.promises.lookup(fixture.hostname, { family: fixture.family })
.then(({ address }) => {
assert.strictEqual(address, fixture.expectedAddress);
}, (err) => {
if (err && err.errno === 'ESERVFAIL') {
assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
} else {
throw err;
}
}).finally(mustCall());

dns.resolve4(fixture.hostname, mustCall((err, addresses) => {
if (err && err.errno === 'ESERVFAIL') {
Expand Down

0 comments on commit 9f594be

Please sign in to comment.