Skip to content

Commit

Permalink
chore(tests): remove hardcoded dns resolver in tests (#9748)
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion authored Nov 14, 2022
1 parent 9247984 commit 004fa2d
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 83 deletions.
4 changes: 2 additions & 2 deletions spec/01-unit/03-conf_loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ describe("Configuration loader", function()
assert.is_nil(conf)

conf, err = conf_loader(nil, {
dns_resolver = "8.8.8.8:53"
dns_resolver = "198.51.100.0:53"
})
assert.is_nil(err)
assert.is_table(conf)
Expand All @@ -667,7 +667,7 @@ describe("Configuration loader", function()
assert.is_table(conf)

conf, err = conf_loader(nil, {
dns_resolver = "8.8.8.8,1.2.3.4:53,::1,[::1]:53"
dns_resolver = "198.51.100.0,1.2.3.4:53,::1,[::1]:53"
})
assert.is_nil(err)
assert.is_table(conf)
Expand Down
4 changes: 2 additions & 2 deletions spec/01-unit/04-prefix_handler_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,11 @@ describe("NGINX conf compiler", function()
end)
it("converts dns_resolver to string", function()
local nginx_conf = prefix_handler.compile_nginx_conf({
dns_resolver = { "8.8.8.8", "8.8.4.4" }
dns_resolver = { "1.2.3.4", "5.6.7.8" }
}, [[
"resolver ${{DNS_RESOLVER}} ipv6=off;"
]])
assert.matches("resolver%s+8%.8%.8%.8 8%.8%.4%.4 ipv6=off;", nginx_conf)
assert.matches("resolver%s+1%.2%.3%.4 5%.6%.7%.8 ipv6=off;", nginx_conf)
end)
end)

Expand Down
7 changes: 4 additions & 3 deletions spec/01-unit/09-balancer/01-generic_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ for _, algorithm in ipairs{ "consistent-hashing", "least-connections", "round-ro
setup_block()
assert(client.init {
hosts = {},
resolvConf = {
"nameserver 8.8.8.8"
},
-- don't supply resolvConf and fallback to default resolver
-- so that CI and docker can have reliable results
-- but remove `search` and `domain`
search = {},
})
snapshot = assert:snapshot()
assert:set_parameter("TableFormatLevel", 10)
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/09-balancer/02-least_connections_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe("[least-connections]", function()
assert(client.init {
hosts = {},
resolvConf = {
"nameserver 8.8.8.8"
"nameserver 198.51.100.0"
},
})
snapshot = assert:snapshot()
Expand Down
7 changes: 4 additions & 3 deletions spec/01-unit/09-balancer/03-consistent_hashing_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ describe("[consistent_hashing]", function()
setup_block()
assert(client.init {
hosts = {},
resolvConf = {
"nameserver 8.8.8.8"
},
-- don't supply resolvConf and fallback to default resolver
-- so that CI and docker can have reliable results
-- but remove `search` and `domain`
search = {},
})
snapshot = assert:snapshot()
end)
Expand Down
14 changes: 8 additions & 6 deletions spec/01-unit/09-balancer/04-round_robin_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,10 @@ describe("[round robin balancer]", function()
setup_block()
assert(client.init {
hosts = {},
resolvConf = {
"nameserver 8.8.8.8"
},
-- don't supply resolvConf and fallback to default resolver
-- so that CI and docker can have reliable results
-- but remove `search` and `domain`
search = {},
})
snapshot = assert:snapshot()
end)
Expand Down Expand Up @@ -1263,9 +1264,10 @@ describe("[round robin balancer]", function()
-- reconfigure the dns client to make sure next query works again
assert(client.init {
hosts = {},
resolvConf = {
"nameserver 8.8.8.8"
},
-- don't supply resolvConf and fallback to default resolver
-- so that CI and docker can have reliable results
-- but remove `search` and `domain`
search = {},
})
dnsA({
{ name = "mashape.test", address = "1.2.3.4" },
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/14-dns_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local function setup_it_block()
client.init {
hosts = {},
resolvConf = {},
nameservers = { "8.8.8.8" },
nameservers = { "198.51.100.0" },
enable_ipv6 = true,
order = { "LAST", "SRV", "A", "CNAME" },
}
Expand Down
18 changes: 9 additions & 9 deletions spec/01-unit/21-dns-client/01-utils_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ describe("[utils]", function()
domain myservice.com
nameserver 8.8.8.8
nameserver 2602:306:bca8:1ac0::1 ; and a comment here
nameserver 8.8.8.8:1234 ; this one has a port number (limited systems support this)
nameserver 198.51.100.0
nameserver 2001:db8::1 ; and a comment here
nameserver 198.51.100.0:1234 ; this one has a port number (limited systems support this)
nameserver 1.2.3.4 ; this one is 4th, so should be ignored
# search is commented out, test below for a mutually exclusive one
Expand Down Expand Up @@ -172,7 +172,7 @@ options use-vc
local resolv, err = dnsutils.parseResolvConf(file)
assert.is.Nil(err)
assert.is.equal("myservice.com", resolv.domain)
assert.is.same({ "8.8.8.8", "2602:306:bca8:1ac0::1", "8.8.8.8:1234" }, resolv.nameserver)
assert.is.same({ "198.51.100.0", "2001:db8::1", "198.51.100.0:1234" }, resolv.nameserver)
assert.is.same({ "list1", "list2" }, resolv.sortlist)
assert.is.same({ ndots = 2, timeout = 3, attempts = 4, debug = true, rotate = true,
["no-check-names"] = true, inet6 = true, ["ip6-bytestring"] = true,
Expand Down Expand Up @@ -221,8 +221,8 @@ search domain1.com domain2.com domain3.com domain4.com domain5.com domain6.com d
[[# this is just a comment line
domain myservice.com
nameserver 8.8.8.8
nameserver 8.8.4.4 ; and a comment here
nameserver 198.51.100.0
nameserver 198.51.100.1 ; and a comment here
options ndots:1
]])
Expand All @@ -244,8 +244,8 @@ options ndots:1
[[# this is just a comment line
domain myservice.com
nameserver 8.8.8.8
nameserver 8.8.4.4 ; and a comment here
nameserver 198.51.100.0
nameserver 198.51.100.1 ; and a comment here
options ndots:2
]])
Expand Down Expand Up @@ -287,7 +287,7 @@ options ndots:2
else
return { -- resolv.conf file
"domain myservice.com",
"nameserver 8.8.8.8 ",
"nameserver 198.51.100.0 ",
}
end
end
Expand Down
Loading

0 comments on commit 004fa2d

Please sign in to comment.