Kong 测试自定义插件发生dns服务器错误:3名称错误
使用以下代码进行kong插件测试时,我遇到了dns服务器错误。 测试用例很容易执行get请求。上游服务是部署在内部k8s集群中的服务。我正在使用Kong 测试自定义插件发生dns服务器错误:3名称错误,kong,openresty,Kong,Openresty,使用以下代码进行kong插件测试时,我遇到了dns服务器错误。 测试用例很容易执行get请求。上游服务是部署在内部k8s集群中的服务。我正在使用kong vagrant在我的windows 10 PC上进行测试 local helpers = require "spec.helpers" local pl_pretty = require "pl.pretty" local PLUGIN_NAME = "myplugin" for
kong vagrant
在我的windows 10 PC上进行测试
local helpers = require "spec.helpers"
local pl_pretty = require "pl.pretty"
local PLUGIN_NAME = "myplugin"
for _, strategy in helpers.each_strategy({"postgres"}) do
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client
lazy_setup(function()
local bp = helpers.get_db_utils(strategy, nil, { PLUGIN_NAME })
local service = bp.services:insert {
name = "service-mockbin",
url = "http://pabc-doc.k8s.io:30283/docs/",
}
-- local service = bp.services:insert {
-- name = "service-mockbin",
-- url = "https://mockbin.com/request",
-- }
local route1 = bp.routes:insert({
paths = { "/docs" },
service = service
})
-- add the plugin to test to the route we created
bp.plugins:insert {
name = PLUGIN_NAME,
route = { id = route1.id },
config = {},
}
-- start kong
assert(helpers.start_kong({
-- set the strategy
database = strategy,
-- use the custom test template to create a local mock server
nginx_conf = "spec/fixtures/custom_nginx.template",
-- make sure our plugin gets loaded
plugins = "bundled," .. PLUGIN_NAME,
}))
end)
lazy_teardown(function()
helpers.stop_kong(nil, true)
end)
before_each(function()
client = helpers.proxy_client()
end)
after_each(function()
if client then client:close() end
end)
describe("request", function()
it("get login", function()
local r = client:get("/docs")
pl_pretty.dump(r)
assert.response(r).has.status(200)
end)
end)
end)
end
错误:
2020/06/23 12:27:49 [error] 4297#0: *2 [lua] balancer.lua:929: execute(): DNS resolution failed: dns server error: 3 name error. Tried: ["(short)pabc-doc.k8s.io:(na) - cache-miss","pabc-doc.k8s.io:33 - cache-hit/dns server error: 3 name error","pabc-doc.k8s.io:1 - cache-hit/dns server error: 3 name error","pabc-doc.k8s.io:5 - cache-hit/dns server error: 3 name error"], client: 127.0.0.1, server: kong, request: "GET /docs HTTP/1.1", host: "0.0.0.0:9000"
如果我启动一个服务并配置上游服务,然后通过浏览器访问它,它就会工作。
并把下面的代码放在自定义插件中,就可以得到ip了
local ip, port, try_list = toip("pabc-doc.k8s.io", 30283, false)
那么,在使用busted
进行测试时,我还应该设置什么来让它工作呢