Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(clustering): clean assertions in batch tests #14177

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions spec/02-integration/18-hybrid_rpc/06-batch-rpc_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,33 @@ for _, strategy in helpers.each_strategy() do
local cp_logfile = nil
local dp_logfile = "servroot2/logs/error.log"

helpers.pwait_until(function()
assert.logfile(dp_logfile).has.line(
"[rpc] sent batch RPC call: 1", true)
assert.logfile(dp_logfile).has.line(
"[rpc] sent batch RPC call: 1", true, 10)

assert.logfile(cp_logfile).has.line(
"[rpc] got batch RPC call: 1", true)
assert.logfile(cp_logfile).has.line(
"kong.test.batch called: world", true)
assert.logfile(cp_logfile).has.line(
"[rpc] got batch RPC call: 1", true, 10)
assert.logfile(cp_logfile).has.line(
"kong.test.batch called: world", true, 10)

assert.logfile(dp_logfile).has.line(
"[rpc] got batch RPC call: 1", true)
assert.logfile(dp_logfile).has.line(
"kong.test.batch called: hello world", true)
assert.logfile(dp_logfile).has.line(
"[rpc] got batch RPC call: 1", true, 10)
assert.logfile(dp_logfile).has.line(
"kong.test.batch called: hello world", true, 10)

assert.logfile(dp_logfile).has.line(
"[rpc] sent batch RPC call: 2", true)
assert.logfile(dp_logfile).has.line(
"[rpc] sent batch RPC call: 2", true, 10)

assert.logfile(cp_logfile).has.line(
"[rpc] got batch RPC call: 2", true)
assert.logfile(cp_logfile).has.line(
"kong.test.batch called: kong", true)
assert.logfile(cp_logfile).has.line(
"kong.test.batch called: gateway", true)
assert.logfile(cp_logfile).has.line(
"[rpc] notification has no response", true)
assert.logfile(cp_logfile).has.line(
"[rpc] got batch RPC call: 2", true, 10)
assert.logfile(cp_logfile).has.line(
"kong.test.batch called: kong", true, 10)
assert.logfile(cp_logfile).has.line(
"kong.test.batch called: gateway", true, 10)
assert.logfile(cp_logfile).has.line(
"[rpc] notification has no response", true, 10)

return true
end, 15)
assert.logfile(dp_logfile).has.line(
"kong.test.batch ok", true, 10)
end)
end)
end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ function RpcBatchTestHandler:init_worker()
worker_events.register(function(capabilities_list)
kong.rpc:__set_batch(1)

local res = kong.rpc:call("control_plane", "kong.test.batch", "world")
if not res then
return
end
local res = assert(kong.rpc:call("control_plane", "kong.test.batch", "world"))

ngx.log(ngx.DEBUG, "kong.test.batch called: ", res)

kong.rpc:__set_batch(2)
kong.rpc:notify("control_plane", "kong.test.batch", "kong")
kong.rpc:notify("control_plane", "kong.test.batch", "gateway")
assert(kong.rpc:notify("control_plane", "kong.test.batch", "kong"))
assert(kong.rpc:notify("control_plane", "kong.test.batch", "gateway"))

ngx.log(ngx.DEBUG, "kong.test.batch ok")
end, "clustering:jsonrpc", "connected")
end

Expand Down
Loading