Skip to content

Commit f3594e7

Browse files
Imran Iqbalrvagg
Imran Iqbal
authored andcommitted
test: fix test-net-persistent-keepalive for AIX
Fixed an intermittent issue on AIX where the 600ms timeout was reached before the 'connection' event was fired. This resulted in a failure as serverConnection would be undefined and the assert.equal would throw an error. Changed the flow of the test so that the timeout is only set after a connection has been made. PR-URL: #3646 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 325c4c7 commit f3594e7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/parallel/test-net-persistent-keepalive.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ var assert = require('assert');
44
var net = require('net');
55

66
var serverConnection;
7+
var clientConnection;
78
var echoServer = net.createServer(function(connection) {
89
serverConnection = connection;
10+
setTimeout(function() {
11+
// make sure both connections are still open
12+
assert.equal(serverConnection.readyState, 'open');
13+
assert.equal(clientConnection.readyState, 'open');
14+
serverConnection.end();
15+
clientConnection.end();
16+
echoServer.close();
17+
}, 600);
918
connection.setTimeout(0);
1019
assert.equal(typeof connection.setKeepAlive, 'function');
1120
connection.on('end', function() {
@@ -15,20 +24,11 @@ var echoServer = net.createServer(function(connection) {
1524
echoServer.listen(common.PORT);
1625

1726
echoServer.on('listening', function() {
18-
var clientConnection = new net.Socket();
27+
clientConnection = new net.Socket();
1928
// send a keepalive packet after 1000 ms
2029
// and make sure it persists
2130
var s = clientConnection.setKeepAlive(true, 400);
2231
assert.ok(s instanceof net.Socket);
2332
clientConnection.connect(common.PORT);
2433
clientConnection.setTimeout(0);
25-
26-
setTimeout(function() {
27-
// make sure both connections are still open
28-
assert.equal(serverConnection.readyState, 'open');
29-
assert.equal(clientConnection.readyState, 'open');
30-
serverConnection.end();
31-
clientConnection.end();
32-
echoServer.close();
33-
}, 600);
3434
});

0 commit comments

Comments
 (0)