From 89f091d621d654b11a2fbe3cd91668f0034d958b Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Fri, 18 Mar 2016 15:57:55 -0400 Subject: [PATCH] test: make test-net-connect-options-ipv6.js better Improve the robustness of test-net-connect-options-ipv6.js PPC Suse build team encountered intermittent failures related to dns. Improve test to make it more robust in the face of intermittent dns issues. PR-URL: https://github.com/nodejs/node/pull/5791 Reviewed-By: James M Snell --- test/parallel/test-net-connect-options-ipv6.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-net-connect-options-ipv6.js b/test/parallel/test-net-connect-options-ipv6.js index 8b11612a1286f2..5cce7325f91967 100644 --- a/test/parallel/test-net-connect-options-ipv6.js +++ b/test/parallel/test-net-connect-options-ipv6.js @@ -40,7 +40,21 @@ function tryConnect() { server.close(); }); }).on('error', function(err) { - if (err.syscall === 'getaddrinfo' && err.code === 'ENOTFOUND') { + // ENOTFOUND means we don't have the requested address. In this + // case we try the next one in the list and if we run out of + // candidates we assume IPv6 is not supported on the + // machine and skip the test. + // EAI_AGAIN means we tried to remotely resolve the address and + // timed out or hit some intermittent connectivity issue with the + // dns server. Although we are looking for local loopback addresses + // we may go remote since the list we search includes addresses that + // cover more than is available on any one distribution. The + // net is that if we get an EAI_AGAIN we were looking for an + // address which does not exist in this distribution so the error + // is not significant and we should just move on and try the + // next address in the list. + if ((err.syscall === 'getaddrinfo') && ((err.code === 'ENOTFOUND') || + (err.code === 'EAI_AGAIN'))) { if (host !== 'localhost' || --localhostTries === 0) host = hosts[++hostIdx]; if (host)