From 140eedc6e1d44b772493d378358462cd9fa12b83 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 31 Mar 2016 21:03:56 -0700 Subject: [PATCH 1/3] test: split out hints from test-dns A few of the hints tests were flaky in CI on pi2-raspbian-wheezy. Moving them to their own file fixes it. It could be that there is an unnoticed interaction with other tests in the file, or it could be that there is a cumulative threshold on some resource that is reached that causes Pi2 to sometimes stall out. (The test was timing out.) Fixes: https://github.com/nodejs/node/issues/5554 --- test/parallel/test-dns-lookup-hints.js | 65 ++++++++++++++++++++++++++ test/parallel/test-dns.js | 56 ---------------------- 2 files changed, 65 insertions(+), 56 deletions(-) create mode 100644 test/parallel/test-dns-lookup-hints.js diff --git a/test/parallel/test-dns-lookup-hints.js b/test/parallel/test-dns-lookup-hints.js new file mode 100644 index 00000000000000..b167a5493a0836 --- /dev/null +++ b/test/parallel/test-dns-lookup-hints.js @@ -0,0 +1,65 @@ +'use strict'; +require('../common'); +var assert = require('assert'); + +var dns = require('dns'); + +function noop() {} + +dns.setServers([]); + +/* + * Make sure that dns.lookup throws if hints does not represent a valid flag. + * (dns.V4MAPPED | dns.ADDRCONFIG) + 1 is invalid because: + * - it's different from dns.V4MAPPED and dns.ADDRCONFIG. + * - it's different from them bitwise ored. + * - it's different from 0. + * - it's an odd number different than 1, and thus is invalid, because + * flags are either === 1 or even. + */ +assert.throws(function() { + dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 }, + noop); +}); + +assert.throws(function() { + dns.lookup('www.google.com'); +}, 'invalid arguments: callback must be passed'); + +assert.throws(function() { + dns.lookup('www.google.com', 4); +}, 'invalid arguments: callback must be passed'); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', 6, noop); +}); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', {}, noop); +}); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', { + family: 4, + hints: 0 + }, noop); +}); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', { + family: 6, + hints: dns.ADDRCONFIG + }, noop); +}); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', { + hints: dns.V4MAPPED + }, noop); +}); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', { + hints: dns.ADDRCONFIG | dns.V4MAPPED + }, noop); +}); diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index d473ae8d952602..da084b5837effe 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -90,62 +90,6 @@ assert.doesNotThrow(function() { dns.lookup(NaN, noop); }); -/* - * Make sure that dns.lookup throws if hints does not represent a valid flag. - * (dns.V4MAPPED | dns.ADDRCONFIG) + 1 is invalid because: - * - it's different from dns.V4MAPPED and dns.ADDRCONFIG. - * - it's different from them bitwise ored. - * - it's different from 0. - * - it's an odd number different than 1, and thus is invalid, because - * flags are either === 1 or even. - */ -assert.throws(function() { - dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 }, - noop); -}); - -assert.throws(function() { - dns.lookup('www.google.com'); -}, 'invalid arguments: callback must be passed'); - -assert.throws(function() { - dns.lookup('www.google.com', 4); -}, 'invalid arguments: callback must be passed'); - -assert.doesNotThrow(function() { - dns.lookup('www.google.com', 6, noop); -}); - -assert.doesNotThrow(function() { - dns.lookup('www.google.com', {}, noop); -}); - -assert.doesNotThrow(function() { - dns.lookup('www.google.com', { - family: 4, - hints: 0 - }, noop); -}); - -assert.doesNotThrow(function() { - dns.lookup('www.google.com', { - family: 6, - hints: dns.ADDRCONFIG - }, noop); -}); - -assert.doesNotThrow(function() { - dns.lookup('www.google.com', { - hints: dns.V4MAPPED - }, noop); -}); - -assert.doesNotThrow(function() { - dns.lookup('www.google.com', { - hints: dns.ADDRCONFIG | dns.V4MAPPED - }, noop); -}); - assert.throws(function() { dns.lookupService('0.0.0.0'); }, /Invalid arguments/); From a748a88ad9ce056f028c5fe053f333ffb06077e5 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 31 Mar 2016 21:37:50 -0700 Subject: [PATCH 2/3] fixup: const-ify --- test/parallel/test-dns-lookup-hints.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-dns-lookup-hints.js b/test/parallel/test-dns-lookup-hints.js index b167a5493a0836..dbe8e5aab7b086 100644 --- a/test/parallel/test-dns-lookup-hints.js +++ b/test/parallel/test-dns-lookup-hints.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var dns = require('dns'); +const dns = require('dns'); function noop() {} From 7ae6f046b78316b395a8c321e479f2eb3870d4e9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 31 Mar 2016 22:38:28 -0700 Subject: [PATCH 3/3] fixup: further split out for more reliability --- test/parallel/test-dns-lookup-hints-family.js | 23 +++++++++++++++++++ test/parallel/test-dns-lookup-hints.js | 14 ----------- 2 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 test/parallel/test-dns-lookup-hints-family.js diff --git a/test/parallel/test-dns-lookup-hints-family.js b/test/parallel/test-dns-lookup-hints-family.js new file mode 100644 index 00000000000000..633593acec7a32 --- /dev/null +++ b/test/parallel/test-dns-lookup-hints-family.js @@ -0,0 +1,23 @@ +'use strict'; +require('../common'); +const assert = require('assert'); + +const dns = require('dns'); + +function noop() {} + +dns.setServers([]); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', { + family: 4, + hints: 0 + }, noop); +}); + +assert.doesNotThrow(function() { + dns.lookup('www.google.com', { + family: 6, + hints: dns.ADDRCONFIG + }, noop); +}); diff --git a/test/parallel/test-dns-lookup-hints.js b/test/parallel/test-dns-lookup-hints.js index dbe8e5aab7b086..c63093d3545caa 100644 --- a/test/parallel/test-dns-lookup-hints.js +++ b/test/parallel/test-dns-lookup-hints.js @@ -38,20 +38,6 @@ assert.doesNotThrow(function() { dns.lookup('www.google.com', {}, noop); }); -assert.doesNotThrow(function() { - dns.lookup('www.google.com', { - family: 4, - hints: 0 - }, noop); -}); - -assert.doesNotThrow(function() { - dns.lookup('www.google.com', { - family: 6, - hints: dns.ADDRCONFIG - }, noop); -}); - assert.doesNotThrow(function() { dns.lookup('www.google.com', { hints: dns.V4MAPPED