summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2015-11-14 20:43:27 -0800
committerRich Trott <rtrott@gmail.com>2015-11-16 13:25:26 -0800
commit5b80ca9339683dd94cc9d7adae99640c4ec9f859 (patch)
treea8657eb6cf1ee9a76869713a4f901dd6b1cb5794 /test
parent3f6b9214bdc6d837a294b72e513348455432be69 (diff)
downloadandroid-node-v8-5b80ca9339683dd94cc9d7adae99640c4ec9f859.tar.gz
android-node-v8-5b80ca9339683dd94cc9d7adae99640c4ec9f859.tar.bz2
android-node-v8-5b80ca9339683dd94cc9d7adae99640c4ec9f859.zip
test: fix flaky SmartOS test
SmartOS has an issue where it will trigger ECONNREFUSED when it should not. See https://smartos.org/bugview/OS-2767. This change adds logic to test-net-server-max-connections.js to work around the issue. Fixes: https://github.com/nodejs/node/issues/2663 PR-URL: https://github.com/nodejs/node/pull/3830 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-net-server-max-connections.js63
1 files changed, 34 insertions, 29 deletions
diff --git a/test/parallel/test-net-server-max-connections.js b/test/parallel/test-net-server-max-connections.js
index 8de27d13eb..2b418e1c3c 100644
--- a/test/parallel/test-net-server-max-connections.js
+++ b/test/parallel/test-net-server-max-connections.js
@@ -36,6 +36,35 @@ function makeConnection(index) {
if (index + 1 < N) {
makeConnection(index + 1);
}
+
+ c.on('close', function() {
+ console.error('closed %d', index);
+ closes++;
+
+ if (closes < N / 2) {
+ assert.ok(server.maxConnections <= index,
+ index +
+ ' was one of the first closed connections ' +
+ 'but shouldnt have been');
+ }
+
+ if (closes === N / 2) {
+ var cb;
+ console.error('calling wait callback.');
+ while (cb = waits.shift()) {
+ cb();
+ }
+ server.close();
+ }
+
+ if (index < server.maxConnections) {
+ assert.equal(true, gotData,
+ index + ' didn\'t get data, but should have');
+ } else {
+ assert.equal(false, gotData,
+ index + ' got data, but shouldn\'t have');
+ }
+ });
});
c.on('end', function() { c.end(); });
@@ -46,36 +75,12 @@ function makeConnection(index) {
});
c.on('error', function(e) {
- console.error('error %d: %s', index, e);
- });
-
- c.on('close', function() {
- console.error('closed %d', index);
- closes++;
-
- if (closes < N / 2) {
- assert.ok(server.maxConnections <= index,
- index +
- ' was one of the first closed connections ' +
- 'but shouldnt have been');
- }
-
- if (closes === N / 2) {
- var cb;
- console.error('calling wait callback.');
- while (cb = waits.shift()) {
- cb();
- }
- server.close();
- }
-
- if (index < server.maxConnections) {
- assert.equal(true, gotData,
- index + ' didn\'t get data, but should have');
- } else {
- assert.equal(false, gotData,
- index + ' got data, but shouldn\'t have');
+ // Retry if SmartOS and ECONNREFUSED. See
+ // https://github.com/nodejs/node/issues/2663.
+ if (common.isSunOS && (e.code === 'ECONNREFUSED')) {
+ c.connect(common.PORT);
}
+ console.error('error %d: %s', index, e);
});
}