Skip to content

Commit

Permalink
test: fix test-net-keepalive for AIX
Browse files Browse the repository at this point in the history
Fixed an intermittent issue on AIX where the 100ms 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.

Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: #3458
  • Loading branch information
Imran Iqbal authored and jasnell committed Oct 21, 2015
1 parent 60a3dd4 commit 87d42b0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/parallel/test-net-keepalive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ var assert = require('assert');
var net = require('net');

var serverConnection;
var clientConnection;
var echoServer = net.createServer(function(connection) {
serverConnection = connection;
setTimeout(function() {
// make sure both connections are still open
assert.equal(serverConnection.readyState, 'open');
assert.equal(clientConnection.readyState, 'open');
serverConnection.end();
clientConnection.end();
echoServer.close();
}, common.platformTimeout(100));
connection.setTimeout(0);
assert.notEqual(connection.setKeepAlive, undefined);
// send a keepalive packet after 50 ms
Expand All @@ -17,15 +26,6 @@ var echoServer = net.createServer(function(connection) {
echoServer.listen(common.PORT);

echoServer.on('listening', function() {
var clientConnection = net.createConnection(common.PORT);
clientConnection = net.createConnection(common.PORT);
clientConnection.setTimeout(0);

setTimeout(function() {
// make sure both connections are still open
assert.equal(serverConnection.readyState, 'open');
assert.equal(clientConnection.readyState, 'open');
serverConnection.end();
clientConnection.end();
echoServer.close();
}, common.platformTimeout(100));
});

0 comments on commit 87d42b0

Please sign in to comment.