Skip to content

Commit

Permalink
basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jan 16, 2025
1 parent 3eb07e7 commit fedc9fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
28 changes: 12 additions & 16 deletions spec/02-integration/18-hybrid_rpc/09-notify_new_version_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,22 @@ for _, strategy in helpers.each_strategy() do
local name = "servroot2/logs/error.log"

-- dp logs
helpers.pwait_until(function()
assert.logfile(name).has.line(
"kong.sync.v2.get_delta ok", true)
assert.logfile(name).has.no.line(
"assertion failed", true)
assert.logfile(name).has.no.line(
"[error]", true)
return true
end, 10)
assert.logfile(name).has.line(
"kong.sync.v2.notify_new_version ok", true, 10)
assert.logfile(name).has.no.line(
"assertion failed", true, 0)
assert.logfile(name).has.no.line(
"[error]", true, 0)

local name = nil

-- cp logs
helpers.pwait_until(function()
assert.logfile(name).has.no.line(
"assertion failed", true)
assert.logfile(name).has.no.line(
"[error]", true)
return true
end, 10)
assert.logfile(name).has.line(
"kong.sync.v2.get_delta ok", true, 10)
assert.logfile(name).has.no.line(
"assertion failed", true, 0)
assert.logfile(name).has.no.line(
"[error]", true, 0)

end)
end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local RpcSyncV2NotifyNewVersioinTestHandler = {
function RpcSyncV2NotifyNewVersioinTestHandler:init_worker()
-- mock function on cp side
kong.rpc.callbacks:register("kong.sync.v2.get_delta", function(node_id, current_versions)
local latest_version = "v02_" .. string.rep("1", 28)
local latest_version = string.format("v02_%028d", 10)

local fake_uuid1 = "00000000-0000-0000-0000-111111111111"
local fake_uuid2 = "00000000-0000-0000-0000-222222222222"
Expand All @@ -38,11 +38,14 @@ function RpcSyncV2NotifyNewVersioinTestHandler:init_worker()
}
}

ngx.log(ngx.DEBUG, "kong.sync.v2.get_delta ok")

return { default = { deltas = deltas, wipe = true, }, }
end)

-- call dp's sync.v2.notify_new_version
kong.rpc.callbacks:register("kong.test.notify_new_version", function(node_id)
return true
end)

local worker_events = assert(kong.worker_events)
Expand All @@ -52,6 +55,8 @@ function RpcSyncV2NotifyNewVersioinTestHandler:init_worker()
local node_id = "control_plane"

local res, err = kong.rpc:call(node_id, "kong.test.notify_new_version")
assert(res == true)
assert(not err)

ngx.log(ngx.DEBUG, "kong.sync.v2.notify_new_version ok")

Expand Down

0 comments on commit fedc9fc

Please sign in to comment.