Skip to content

Commit

Permalink
tests(clustering): clean assertions in batch call tests (#14177)
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw authored Jan 17, 2025
1 parent ce15c78 commit 902e16a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
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

1 comment on commit 902e16a

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong-dev:902e16a1eb0ddb44385af3828de3e3f091a2196e
Artifacts available https://github.com/Kong/kong/actions/runs/12821288485

Please sign in to comment.