Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lhanjian committed Dec 20, 2024
1 parent ef07a4a commit 3aa41c2
Showing 1 changed file with 81 additions and 83 deletions.
164 changes: 81 additions & 83 deletions spec/02-integration/09-hybrid_mode/11-status_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,114 +104,112 @@ for _, strategy in helpers.each_strategy() do
end)

-- now dp receive config from cp, so dp should be ready
if rpc_sync == "off" then
it("should return 200 on data plane after configuring", function()
helpers.wait_until(function()
local http_client = helpers.http_client('127.0.0.1', dp_status_port)
local it_no_rpc_sync = rpc_sync == "off" and it or pending
it_no_rpc_sync("should return 200 on data plane after configuring", function()
helpers.wait_until(function()
local http_client = helpers.http_client('127.0.0.1', dp_status_port)

local res = http_client:send({
method = "GET",
path = "/status/ready",
})
local res = http_client:send({
method = "GET",
path = "/status/ready",
})

local status = res and res.status
http_client:close()
if status == 200 then
return true
end
end, 10)
local status = res and res.status
http_client:close()
if status == 200 then
return true
end
end, 10)

assert(helpers.stop_kong("serve_cp", nil, nil, "QUIT", false))
assert(helpers.stop_kong("serve_cp", nil, nil, "QUIT", false))

-- DP should keep return 200 after CP is shut down
helpers.wait_until(function()
-- DP should keep return 200 after CP is shut down
helpers.wait_until(function()

local http_client = helpers.http_client('127.0.0.1', dp_status_port)
local http_client = helpers.http_client('127.0.0.1', dp_status_port)

local res = http_client:send({
method = "GET",
path = "/status/ready",
})
local res = http_client:send({
method = "GET",
path = "/status/ready",
})

local status = res and res.status
http_client:close()
if status == 200 then
return true
end
end, 10)
local status = res and res.status
http_client:close()
if status == 200 then
return true
end
end, 10)

-- recovery state between tests
assert(start_kong_cp())
-- recovery state between tests
assert(start_kong_cp())

helpers.wait_until(function()
local http_client = helpers.http_client('127.0.0.1', dp_status_port)
helpers.wait_until(function()
local http_client = helpers.http_client('127.0.0.1', dp_status_port)

local res = http_client:send({
method = "GET",
path = "/status/ready",
})
local res = http_client:send({
method = "GET",
path = "/status/ready",
})

local status = res and res.status
http_client:close()
if status == 200 then
return true
end
end, 10)
end)
end
local status = res and res.status
http_client:close()
if status == 200 then
return true
end
end, 10)
end)
end)

if rpc == "on" and rpc_sync == "on" then
describe("dp status ready when rpc_sync == on", function()
lazy_setup(function()
assert(start_kong_cp())
assert(start_kong_dp())
end)
describe("dp status ready when rpc_sync == on", function()
lazy_setup(function()
assert(start_kong_cp())
assert(start_kong_dp())
end)

lazy_teardown(function()
assert(helpers.stop_kong("serve_cp"))
assert(helpers.stop_kong("serve_dp"))
end)
lazy_teardown(function()
assert(helpers.stop_kong("serve_cp"))
assert(helpers.stop_kong("serve_dp"))
end)

it("should return 200 on data plane after configuring when rpc_sync == on", function()
-- insert one entity to make dp ready for incremental sync
local it_rpc_sync_on = rpc == "on" and rpc_sync == "on" and it or pending
it_rpc_sync_on("should return 200 on data plane after configuring when rpc_sync == on", function()
-- insert one entity to make dp ready for incremental sync

local http_client = helpers.http_client('127.0.0.1', dp_status_port)

local res = http_client:send({
method = "GET",
path = "/status/ready",
})
http_client:close()
assert.equal(503, res.status)

local admin_client = helpers.admin_client(10000)
local res = assert(admin_client:post("/services", {
body = { name = "service-001", url = "https://127.0.0.1:15556/request", },
headers = {["Content-Type"] = "application/json"}
}))
assert.res_status(201, res)

admin_client:close()

helpers.wait_until(function()
local http_client = helpers.http_client('127.0.0.1', dp_status_port)

local res = http_client:send({
method = "GET",
path = "/status/ready",
})
http_client:close()
assert.equal(503, res.status)

local admin_client = helpers.admin_client(10000)
local res = assert(admin_client:post("/services", {
body = { name = "service-001", url = "https://127.0.0.1:15556/request", },
headers = {["Content-Type"] = "application/json"}
}))
assert.res_status(201, res)

admin_client:close()

helpers.wait_until(function()
local http_client = helpers.http_client('127.0.0.1', dp_status_port)

local res = http_client:send({
method = "GET",
path = "/status/ready",
})

local status = res and res.status
http_client:close()
local status = res and res.status
http_client:close()

if status == 200 then
return true
end
end, 10)
end)
if status == 200 then
return true
end
end, 10)
end)
end
end)
end)
end -- for _, strategy
end -- for rpc_sync

0 comments on commit 3aa41c2

Please sign in to comment.