commit
8f413c4231
3 changed files with 3 additions and 3 deletions
|
@ -274,7 +274,7 @@ end
|
||||||
function _M.init_worker()
|
function _M.init_worker()
|
||||||
-- when worker starts, sync backends without delay
|
-- when worker starts, sync backends without delay
|
||||||
-- we call it in timer because for endpoints that require
|
-- we call it in timer because for endpoints that require
|
||||||
-- DNS resolution it needs to use socket which is not avalable in
|
-- DNS resolution it needs to use socket which is not available in
|
||||||
-- init_worker phase
|
-- init_worker phase
|
||||||
local ok, err = ngx.timer.at(0, sync_backends)
|
local ok, err = ngx.timer.at(0, sync_backends)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
|
|
@ -57,7 +57,7 @@ describe("dns.lookup", function()
|
||||||
assert.spy(spy_ngx_log).was_called_with(ngx.ERR, "failed to query the DNS server for ", "example.com", ":\n", "server returned error code: 1: format error\nserver returned error code: 1: format error")
|
assert.spy(spy_ngx_log).was_called_with(ngx.ERR, "failed to query the DNS server for ", "example.com", ":\n", "server returned error code: 1: format error\nserver returned error code: 1: format error")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("retuns host when there's answer but no A/AAAA record in it", function()
|
it("returns host when there's answer but no A/AAAA record in it", function()
|
||||||
helpers.mock_resty_dns_query(nil, { { name = "example.com", cname = "sub.example.com", ttl = 60 } })
|
helpers.mock_resty_dns_query(nil, { { name = "example.com", cname = "sub.example.com", ttl = 60 } })
|
||||||
assert.are.same({ "example.com" }, dns_lookup("example.com"))
|
assert.are.same({ "example.com" }, dns_lookup("example.com"))
|
||||||
assert.spy(spy_ngx_log).was_called_with(ngx.ERR, "failed to query the DNS server for ", "example.com", ":\n", "no A record resolved\nno AAAA record resolved")
|
assert.spy(spy_ngx_log).was_called_with(ngx.ERR, "failed to query the DNS server for ", "example.com", ":\n", "no A record resolved\nno AAAA record resolved")
|
||||||
|
|
|
@ -173,7 +173,7 @@ local function tablelength(T)
|
||||||
end
|
end
|
||||||
_M.tablelength = tablelength
|
_M.tablelength = tablelength
|
||||||
|
|
||||||
-- replaces special character value a with value b for all occurences in a
|
-- replaces special character value a with value b for all occurrences in a
|
||||||
-- string
|
-- string
|
||||||
local function replace_special_char(str, a, b)
|
local function replace_special_char(str, a, b)
|
||||||
return string.gsub(str, "%" .. a, b)
|
return string.gsub(str, "%" .. a, b)
|
||||||
|
|
Loading…
Reference in a new issue