Skip to content

Commit 2d7466e

Browse files
treysisnodejs-github-bot
authored andcommitted
dns: test suite fixes for CI
PR-URL: #39987 Fixes: #31566 Refs: #6307 Refs: #20710 Refs: #38099 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 73c32d5 commit 2d7466e

File tree

6 files changed

+34
-20
lines changed

6 files changed

+34
-20
lines changed

test/parallel/test-net-connect-options-port.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const net = require('net');
8383
}
8484
}, expectedConnections));
8585

86-
server.listen(0, 'localhost', common.mustCall(() => {
86+
server.listen(0, common.localhostIPv4, common.mustCall(() => {
8787
const port = server.address().port;
8888

8989
// Total connections = 3 * 4(canConnect) * 6(doConnect) = 72
@@ -133,28 +133,35 @@ function doConnect(args, getCb) {
133133
}
134134

135135
function syncFailToConnect(port, assertErr, optOnly) {
136+
const family = 4;
136137
if (!optOnly) {
137138
// connect(port, cb) and connect(port)
138-
const portArgFunctions = doConnect([port], () => common.mustNotCall());
139+
const portArgFunctions = doConnect([{ port, family }],
140+
() => common.mustNotCall());
139141
for (const fn of portArgFunctions) {
140142
assert.throws(fn, assertErr, `${fn.name}(${port})`);
141143
}
142144

143145
// connect(port, host, cb) and connect(port, host)
144-
const portHostArgFunctions = doConnect([port, 'localhost'],
146+
const portHostArgFunctions = doConnect([{ port,
147+
host: 'localhost',
148+
family }],
145149
() => common.mustNotCall());
146150
for (const fn of portHostArgFunctions) {
147151
assert.throws(fn, assertErr, `${fn.name}(${port}, 'localhost')`);
148152
}
149153
}
150154
// connect({port}, cb) and connect({port})
151-
const portOptFunctions = doConnect([{ port }], () => common.mustNotCall());
155+
const portOptFunctions = doConnect([{ port, family }],
156+
() => common.mustNotCall());
152157
for (const fn of portOptFunctions) {
153158
assert.throws(fn, assertErr, `${fn.name}({port: ${port}})`);
154159
}
155160

156161
// connect({port, host}, cb) and connect({port, host})
157-
const portHostOptFunctions = doConnect([{ port: port, host: 'localhost' }],
162+
const portHostOptFunctions = doConnect([{ port: port,
163+
host: 'localhost',
164+
family: family }],
158165
() => common.mustNotCall());
159166
for (const fn of portHostOptFunctions) {
160167
assert.throws(fn,
@@ -165,27 +172,30 @@ function syncFailToConnect(port, assertErr, optOnly) {
165172

166173
function canConnect(port) {
167174
const noop = () => common.mustCall();
175+
const family = 4;
168176

169177
// connect(port, cb) and connect(port)
170-
const portArgFunctions = doConnect([port], noop);
178+
const portArgFunctions = doConnect([{ port, family }], noop);
171179
for (const fn of portArgFunctions) {
172180
fn();
173181
}
174182

175183
// connect(port, host, cb) and connect(port, host)
176-
const portHostArgFunctions = doConnect([port, 'localhost'], noop);
184+
const portHostArgFunctions = doConnect([{ port, host: 'localhost', family }],
185+
noop);
177186
for (const fn of portHostArgFunctions) {
178187
fn();
179188
}
180189

181190
// connect({port}, cb) and connect({port})
182-
const portOptFunctions = doConnect([{ port }], noop);
191+
const portOptFunctions = doConnect([{ port, family }], noop);
183192
for (const fn of portOptFunctions) {
184193
fn();
185194
}
186195

187196
// connect({port, host}, cb) and connect({port, host})
188-
const portHostOptFns = doConnect([{ port, host: 'localhost' }], noop);
197+
const portHostOptFns = doConnect([{ port, host: 'localhost', family }],
198+
noop);
189199
for (const fn of portHostOptFns) {
190200
fn();
191201
}
@@ -198,20 +208,22 @@ function asyncFailToConnect(port) {
198208
});
199209

200210
const dont = () => common.mustNotCall();
211+
const family = 4;
201212
// connect(port, cb) and connect(port)
202-
const portArgFunctions = doConnect([port], dont);
213+
const portArgFunctions = doConnect([{ port, family }], dont);
203214
for (const fn of portArgFunctions) {
204215
fn().on('error', onError());
205216
}
206217

207218
// connect({port}, cb) and connect({port})
208-
const portOptFunctions = doConnect([{ port }], dont);
219+
const portOptFunctions = doConnect([{ port, family }], dont);
209220
for (const fn of portOptFunctions) {
210221
fn().on('error', onError());
211222
}
212223

213224
// connect({port, host}, cb) and connect({port, host})
214-
const portHostOptFns = doConnect([{ port, host: 'localhost' }], dont);
225+
const portHostOptFns = doConnect([{ port, host: 'localhost', family }],
226+
dont);
215227
for (const fn of portHostOptFns) {
216228
fn().on('error', onError());
217229
}

test/parallel/test-net-pingpong.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,4 @@ const tmpdir = require('../common/tmpdir');
130130
tmpdir.refresh();
131131
pingPongTest(common.PIPE);
132132
pingPongTest(0);
133-
pingPongTest(0, 'localhost');
134-
if (common.hasIPv6)
135-
pingPongTest(0, '::1');
133+
common.hasIPv6 ? pingPongTest(0, '::1') : pingPongTest(0, '127.0.0.1');

test/parallel/test-net-remote-address-port.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ const remoteFamilyCandidates = ['IPv4'];
3434
if (common.hasIPv6) remoteFamilyCandidates.push('IPv6');
3535

3636
const server = net.createServer(common.mustCall(function(socket) {
37-
assert.ok(remoteAddrCandidates.includes(socket.remoteAddress));
37+
// test to see real value in CI log
38+
assert.match(socket.remoteAddress,
39+
/^127\.0\.0\.1$|^::1$|^::ffff:127.0.0.1$/);
40+
// assert.ok(remoteAddrCandidates.includes(socket.remoteAddress));
3841
assert.ok(remoteFamilyCandidates.includes(socket.remoteFamily));
3942
assert.ok(socket.remotePort);
4043
assert.notStrictEqual(socket.remotePort, this.address().port);

test/parallel/test-net-writable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const server = net.createServer(common.mustCall(function(s) {
77
server.close();
88
s.end();
99
})).listen(0, 'localhost', common.mustCall(function() {
10-
const socket = net.connect(this.address().port, 'localhost');
10+
const socket = net.connect(this.address().port, common.hasIPv6 ?
11+
'::1' :
12+
'127.0.0.1');
1113
socket.on('end', common.mustCall(() => {
1214
assert.strictEqual(socket.writable, true);
1315
socket.write('hello world');

test/pummel/test-net-pingpong.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,8 @@ function pingPongTest(host, on_complete) {
111111
}
112112

113113
// All are run at once and will run on different ports.
114-
pingPongTest('localhost');
115114
pingPongTest(null);
116-
117-
if (common.hasIPv6) pingPongTest('::1');
115+
common.hasIPv6 ? pingPongTest('::1') : pingPongTest('127.0.0.1');
118116

119117
process.on('exit', function() {
120118
assert.strictEqual(tests_run, common.hasIPv6 ? 3 : 2);

test/sequential/test-https-connect-localport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const assert = require('assert');
2323
host: 'localhost',
2424
pathname: '/',
2525
port,
26+
family: common.hasIPv6 ? 6 : 4,
2627
localPort: common.PORT,
2728
rejectUnauthorized: false,
2829
}, common.mustCall(() => {

0 commit comments

Comments
 (0)