Skip to content

Commit

Permalink
01-sync_spec.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Dec 15, 2022
1 parent e4a0324 commit 630a4c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
31 changes: 24 additions & 7 deletions spec/02-integration/09-hybrid_mode/01-sync_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ local CLUSTERING_SYNC_STATUS = require("kong.constants").CLUSTERING_SYNC_STATUS
local KEY_AUTH_PLUGIN


for wrpc_protocol in ipairs{ true, false } do
for _, strategy in helpers.each_strategy() do

describe("CP/DP communication #" .. strategy, function()
describe("CP/DP communication #" .. strategy .. ", wrpc=" .. tostring(wrpc_protocol), function()

lazy_setup(function()
helpers.get_db_utils(strategy) -- runs migrations
Expand All @@ -31,6 +32,7 @@ describe("CP/DP communication #" .. strategy, function()

assert(helpers.start_kong({
role = "data_plane",
wrpc_hybrid_protocol = wrpc_protocol,
database = "off",
prefix = "servroot2",
cluster_cert = "spec/fixtures/kong_clustering.crt",
Expand Down Expand Up @@ -339,7 +341,7 @@ describe("CP/DP communication #" .. strategy, function()
end)
end)

describe("CP/DP #version check #" .. strategy, function()
describe("CP/DP #version check #" .. strategy .. ", wrpc=" .. tostring(wrpc_protocol), function()
-- for these tests, we do not need a real DP, but rather use the fake DP
-- client so we can mock various values (e.g. node_version)
describe("relaxed compatibility check:", function()
Expand Down Expand Up @@ -476,6 +478,7 @@ describe("CP/DP #version check #" .. strategy, function()
local uuid = utils.uuid()

local res = assert(helpers.clustering_client({
wrpc_protocol = wrpc_protocol,
host = "127.0.0.1",
port = 9005,
cert = "spec/fixtures/kong_clustering.crt",
Expand All @@ -485,8 +488,15 @@ describe("CP/DP #version check #" .. strategy, function()
node_plugins_list = harness.plugins_list,
}))

assert.equals("reconfigure", res.type)
assert.is_table(res.config_table)
if wrpc_protocol then
assert.is_table(res)
assert(res.version)
assert(res.config)

else
assert.equals("reconfigure", res.type)
assert.is_table(res.config_table)
end

-- needs wait_until for C* convergence
helpers.wait_until(function()
Expand Down Expand Up @@ -561,6 +571,7 @@ describe("CP/DP #version check #" .. strategy, function()
local uuid = utils.uuid()

local res, err = helpers.clustering_client({
wrpc_protocol = wrpc_protocol,
host = "127.0.0.1",
port = 9005,
cert = "spec/fixtures/kong_clustering.crt",
Expand All @@ -576,8 +587,12 @@ describe("CP/DP #version check #" .. strategy, function()
end

else
-- is not config result
assert.equals("PONG", res)
if wrpc_protocol then -- wrpc
-- is not config result
assert((res.error or res.ok) and not res.config)
else
assert.equals("PONG", res)
end
end

-- needs wait_until for c* convergence
Expand Down Expand Up @@ -605,7 +620,7 @@ describe("CP/DP #version check #" .. strategy, function()
end)
end)

describe("CP/DP config sync #" .. strategy, function()
describe("CP/DP config sync #" .. strategy .. ", wrpc=" .. tostring(wrpc_protocol), function()
lazy_setup(function()
helpers.get_db_utils(strategy) -- runs migrations

Expand All @@ -620,6 +635,7 @@ describe("CP/DP config sync #" .. strategy, function()

assert(helpers.start_kong({
role = "data_plane",
wrpc_hybrid_protocol = wrpc_protocol,
database = "off",
prefix = "servroot2",
cluster_cert = "spec/fixtures/kong_clustering.crt",
Expand Down Expand Up @@ -716,3 +732,4 @@ describe("CP/DP config sync #" .. strategy, function()
end)

end
end
2 changes: 1 addition & 1 deletion spec/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3482,7 +3482,7 @@ do
end

local function clustering_client(opts)
if opts.cluster_protocol == "wrpc" then
if opts.wrpc_protocol then -- wrpc
return clustering_client_wrpc(opts)
else
return clustering_client_json(opts)
Expand Down

0 comments on commit 630a4c1

Please sign in to comment.