From a77c29a0f981451dec3430d1e46bc77518e30ead Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 18 Feb 2013 18:26:29 -0800 Subject: [PATCH] test: Fix tls tests which fail sporadically The count of ECONNRESETs is dependent on timing, and thus unreliable, especially on Linux machines. --- test/simple/test-tls-over-http-tunnel.js | 8 +++++--- test/simple/test-tls-session-cache.js | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test/simple/test-tls-over-http-tunnel.js b/test/simple/test-tls-over-http-tunnel.js index d4bccf5..4cb0a52 100644 --- a/test/simple/test-tls-over-http-tunnel.js +++ b/test/simple/test-tls-over-http-tunnel.js @@ -34,7 +34,6 @@ var https = require('https'); var proxyPort = common.PORT + 1; var gotRequest = false; -var errorCount = 0; var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); @@ -164,12 +163,15 @@ proxy.listen(proxyPort, function() { server.close(); }); }).on('error', function() { - errorCount++; + // We're ok with getting ECONNRESET in this test, but it's + // timing-dependent, and thus unreliable. Any other errors + // are just failures, though. + if (er.code !== 'ECONNRESET') + throw er; }).end(); } }); process.on('exit', function() { assert.ok(gotRequest); - assert.equal(errorCount, 1); }); diff --git a/test/simple/test-tls-session-cache.js b/test/simple/test-tls-session-cache.js index 2bfac0d..695a759 100644 --- a/test/simple/test-tls-session-cache.js +++ b/test/simple/test-tls-session-cache.js @@ -50,12 +50,15 @@ function doTest() { requestCert: true }; var requestCount = 0; - var errorCount = 0; var session; var server = tls.createServer(options, function(cleartext) { - cleartext.on('error', function() { - errorCount++; + cleartext.on('error', function(er) { + // We're ok with getting ECONNRESET in this test, but it's + // timing-dependent, and thus unreliable. Any other errors + // are just failures, though. + if (er.code !== 'ECONNRESET') + throw er; }); ++requestCount; cleartext.end(); @@ -98,6 +101,5 @@ function doTest() { // initial request + reconnect requests (5 times) assert.equal(requestCount, 6); - assert.equal(errorCount, 4); }); } -- 2.7.4