test: fix flaky test-dns and test-dns-lookup · nodejs/node@c704faa · GitHub
Skip to content

Commit c704faa

Browse files
committed
test: fix flaky test-dns and test-dns-lookup
Ubuntu 16.04 is going to be unsupported after April 2021. Switching Node.js CI to Ubuntu 18.04 for the internet tests resulted in failures in test-dns and test-dns-lookup because it returns server failure/try again on .invalid domain. Add a hostname for testing that will return record not found. PR-URL: #38282 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent d666964 commit c704faa

3 files changed

Lines changed: 39 additions & 36 deletions

File tree

test/common/internet.js

Lines changed: 3 additions & 0 deletions

test/internet/test-dns-lookup.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,39 @@ const { addresses } = require('../common/internet');
88
const assert = require('assert');
99

1010
assert.rejects(
11-
dnsPromises.lookup(addresses.INVALID_HOST, {
11+
dnsPromises.lookup(addresses.NOT_FOUND, {
1212
hints: 0,
1313
family: 0,
1414
all: false
1515
}),
1616
{
1717
code: 'ENOTFOUND',
18-
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
18+
message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`
1919
}
2020
);
2121

2222
assert.rejects(
23-
dnsPromises.lookup(addresses.INVALID_HOST, {
23+
dnsPromises.lookup(addresses.NOT_FOUND, {
2424
hints: 0,
2525
family: 0,
2626
all: true
2727
}),
2828
{
2929
code: 'ENOTFOUND',
30-
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
30+
message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`
3131
}
3232
);
3333

34-
dns.lookup(addresses.INVALID_HOST, {
34+
dns.lookup(addresses.NOT_FOUND, {
3535
hints: 0,
3636
family: 0,
3737
all: true
3838
}, common.mustCall((error) => {
3939
assert.strictEqual(error.code, 'ENOTFOUND');
4040
assert.strictEqual(
4141
error.message,
42-
`getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
42+
`getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`
4343
);
4444
assert.strictEqual(error.syscall, 'getaddrinfo');
45-
assert.strictEqual(error.hostname, addresses.INVALID_HOST);
45+
assert.strictEqual(error.hostname, addresses.NOT_FOUND);
4646
}));

test/internet/test-dns.js

Lines changed: 29 additions & 29 deletions

0 commit comments

Comments
 (0)